mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
I think exceptions module is utility.
This commit is contained in:
parent
38bad5454e
commit
2346ade309
3 changed files with 3 additions and 3 deletions
|
|
@ -1,39 +0,0 @@
|
|||
def _clean_message(text):
|
||||
return text. \
|
||||
lstrip('Error: '). \
|
||||
lstrip('[Error]: '). \
|
||||
lstrip('Bad Request: '). \
|
||||
capitalize()
|
||||
|
||||
|
||||
class TelegramAPIError(Exception):
|
||||
def __init__(self, message):
|
||||
super(TelegramAPIError, self).__init__(_clean_message(message))
|
||||
|
||||
|
||||
class ValidationError(TelegramAPIError):
|
||||
pass
|
||||
|
||||
|
||||
class BadRequest(TelegramAPIError):
|
||||
pass
|
||||
|
||||
|
||||
class Unauthorized(TelegramAPIError):
|
||||
pass
|
||||
|
||||
|
||||
class NetworkError(TelegramAPIError):
|
||||
pass
|
||||
|
||||
|
||||
class RetryAfter(TelegramAPIError):
|
||||
def __init__(self, retry_after):
|
||||
super(RetryAfter, self).__init__(f"Flood control exceeded. Retry in {retry_after} seconds.")
|
||||
self.timeout = retry_after
|
||||
|
||||
|
||||
class MigrateToChat(TelegramAPIError):
|
||||
def __init__(self, chat_id):
|
||||
super(MigrateToChat, self).__init__(f"The group has been migrated to a supergroup. New id: {chat_id}.")
|
||||
self.migrate_to_chat_id = chat_id
|
||||
Loading…
Add table
Add a link
Reference in a new issue