mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
New error types.
This commit is contained in:
parent
1f8b2b464e
commit
3076173384
2 changed files with 14 additions and 0 deletions
|
|
@ -79,6 +79,8 @@ async def _check_result(method_name, response):
|
||||||
raise exceptions.NetworkError('File too large for uploading. '
|
raise exceptions.NetworkError('File too large for uploading. '
|
||||||
'Check telegram api limits https://core.telegram.org/bots/api#senddocument')
|
'Check telegram api limits https://core.telegram.org/bots/api#senddocument')
|
||||||
elif response.status >= HTTPStatus.INTERNAL_SERVER_ERROR:
|
elif response.status >= HTTPStatus.INTERNAL_SERVER_ERROR:
|
||||||
|
if 'restart' in description:
|
||||||
|
raise exceptions.RestartingTelegram()
|
||||||
raise exceptions.TelegramAPIError(description)
|
raise exceptions.TelegramAPIError(description)
|
||||||
raise exceptions.TelegramAPIError(f"{description} [{response.status}]")
|
raise exceptions.TelegramAPIError(f"{description} [{response.status}]")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ TelegramAPIError
|
||||||
BadWebhook
|
BadWebhook
|
||||||
WebhookRequireHTTPS
|
WebhookRequireHTTPS
|
||||||
BadWebhookPort
|
BadWebhookPort
|
||||||
|
BadWebhookAddrInfo
|
||||||
CantParseUrl
|
CantParseUrl
|
||||||
NotFound
|
NotFound
|
||||||
MethodNotKnown
|
MethodNotKnown
|
||||||
|
|
@ -39,6 +40,7 @@ TelegramAPIError
|
||||||
NetworkError
|
NetworkError
|
||||||
RetryAfter
|
RetryAfter
|
||||||
MigrateToChat
|
MigrateToChat
|
||||||
|
RestartingTelegram
|
||||||
|
|
||||||
AIOGramWarning
|
AIOGramWarning
|
||||||
TimeoutWarning
|
TimeoutWarning
|
||||||
|
|
@ -232,6 +234,11 @@ class BadWebhookPort(BadWebhook):
|
||||||
text = 'bad webhook: ' + match
|
text = 'bad webhook: ' + match
|
||||||
|
|
||||||
|
|
||||||
|
class BadWebhookAddrInfo(BadWebhook):
|
||||||
|
match = 'getaddrinfo: Temporary failure in name resolution'
|
||||||
|
text = 'bad webhook: ' + match
|
||||||
|
|
||||||
|
|
||||||
class CantParseUrl(BadRequest):
|
class CantParseUrl(BadRequest):
|
||||||
match = 'can\'t parse URL'
|
match = 'can\'t parse URL'
|
||||||
|
|
||||||
|
|
@ -282,6 +289,11 @@ class NetworkError(TelegramAPIError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RestartingTelegram(TelegramAPIError):
|
||||||
|
def __init__(self):
|
||||||
|
super(RestartingTelegram, self).__init__('The Telegram Bot API service is restarting. Wait few second.')
|
||||||
|
|
||||||
|
|
||||||
class RetryAfter(TelegramAPIError):
|
class RetryAfter(TelegramAPIError):
|
||||||
def __init__(self, retry_after):
|
def __init__(self, retry_after):
|
||||||
super(RetryAfter, self).__init__(f"Flood control exceeded. Retry in {retry_after} seconds.")
|
super(RetryAfter, self).__init__(f"Flood control exceeded. Retry in {retry_after} seconds.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue