New error types.

This commit is contained in:
Alex Root Junior 2018-05-11 02:00:32 +03:00
parent 1f8b2b464e
commit 3076173384
2 changed files with 14 additions and 0 deletions

View file

@ -19,6 +19,7 @@ TelegramAPIError
BadWebhook
WebhookRequireHTTPS
BadWebhookPort
BadWebhookAddrInfo
CantParseUrl
NotFound
MethodNotKnown
@ -39,6 +40,7 @@ TelegramAPIError
NetworkError
RetryAfter
MigrateToChat
RestartingTelegram
AIOGramWarning
TimeoutWarning
@ -232,6 +234,11 @@ class BadWebhookPort(BadWebhook):
text = 'bad webhook: ' + match
class BadWebhookAddrInfo(BadWebhook):
match = 'getaddrinfo: Temporary failure in name resolution'
text = 'bad webhook: ' + match
class CantParseUrl(BadRequest):
match = 'can\'t parse URL'
@ -282,6 +289,11 @@ class NetworkError(TelegramAPIError):
pass
class RestartingTelegram(TelegramAPIError):
def __init__(self):
super(RestartingTelegram, self).__init__('The Telegram Bot API service is restarting. Wait few second.')
class RetryAfter(TelegramAPIError):
def __init__(self, retry_after):
super(RetryAfter, self).__init__(f"Flood control exceeded. Retry in {retry_after} seconds.")