From f0de1c5761e3b89bbad33a7dca7d78bb38a0549d Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 8 Apr 2018 17:31:58 +0300 Subject: [PATCH] Add PhotoAsInputFileRequired exception. // Photo should be uploaded as an InputFile --- aiogram/bot/api.py | 2 ++ aiogram/utils/exceptions.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index bb92f8b2..123c5359 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -91,6 +91,8 @@ async def _check_result(method_name, response): exceptions.BadWebhookPort.throw() elif exceptions.CantParseUrl.check(description): exceptions.CantParseUrl.throw() + elif exceptions.PhotoAsInputFileRequired.check(description): + exceptions.PhotoAsInputFileRequired.throw() raise exceptions.BadRequest(description) elif response.status == HTTPStatus.NOT_FOUND: if exceptions.MethodNotKnown.check(description): diff --git a/aiogram/utils/exceptions.py b/aiogram/utils/exceptions.py index f7296eae..16fef497 100644 --- a/aiogram/utils/exceptions.py +++ b/aiogram/utils/exceptions.py @@ -130,6 +130,10 @@ class GroupDeactivated(BadRequest, _MatchErrorMixin): match = 'group is deactivated' +class PhotoAsInputFileRequired(BadRequest, _MatchErrorMixin): + match = 'Photo should be uploaded as an InputFile' + + class BadWebhook(BadRequest): pass