mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Moooore error types.
This commit is contained in:
parent
59bde14db3
commit
ebc0a94201
1 changed files with 69 additions and 10 deletions
|
|
@ -9,8 +9,13 @@ TelegramAPIError
|
||||||
MessageToDeleteNotFound
|
MessageToDeleteNotFound
|
||||||
MessageIdentifierNotSpecified
|
MessageIdentifierNotSpecified
|
||||||
MessageTextIsEmpty
|
MessageTextIsEmpty
|
||||||
|
MessageCantBeEdited
|
||||||
|
MessageToEditNotFound
|
||||||
ToMuchMessages
|
ToMuchMessages
|
||||||
|
ObjectExpectedAsReplyMarkup
|
||||||
|
InlineKeyboardExpected
|
||||||
ChatNotFound
|
ChatNotFound
|
||||||
|
ChatDescriptionIsNotModified
|
||||||
InvalidQueryID
|
InvalidQueryID
|
||||||
InvalidPeerID
|
InvalidPeerID
|
||||||
InvalidHTTPUrlContent
|
InvalidHTTPUrlContent
|
||||||
|
|
@ -29,11 +34,19 @@ TelegramAPIError
|
||||||
MethodNotKnown
|
MethodNotKnown
|
||||||
PhotoAsInputFileRequired
|
PhotoAsInputFileRequired
|
||||||
InvalidStickersSet
|
InvalidStickersSet
|
||||||
|
NoStickerInRequest
|
||||||
ChatAdminRequired
|
ChatAdminRequired
|
||||||
|
NotEnoughRightsToPinMessage
|
||||||
|
CantDemoteChatCreator
|
||||||
CantRestrictSelf
|
CantRestrictSelf
|
||||||
PhotoDimensions
|
PhotoDimensions
|
||||||
UnavailableMembers
|
UnavailableMembers
|
||||||
TypeOfFileMismatch
|
TypeOfFileMismatch
|
||||||
|
WrongRemoteFileIdSpecified
|
||||||
|
PaymentProviderInvalid
|
||||||
|
CurrencyTotalAmountInvalid
|
||||||
|
CantParseUrl
|
||||||
|
CantParseEntities
|
||||||
ConflictError
|
ConflictError
|
||||||
TerminatedByOtherGetUpdates
|
TerminatedByOtherGetUpdates
|
||||||
CantGetUpdates
|
CantGetUpdates
|
||||||
|
|
@ -42,6 +55,7 @@ TelegramAPIError
|
||||||
BotBlocked
|
BotBlocked
|
||||||
UserDeactivated
|
UserDeactivated
|
||||||
CantInitiateConversation
|
CantInitiateConversation
|
||||||
|
CantTalkWithBots
|
||||||
NetworkError
|
NetworkError
|
||||||
RetryAfter
|
RetryAfter
|
||||||
MigrateToChat
|
MigrateToChat
|
||||||
|
|
@ -91,15 +105,6 @@ class _MatchErrorMixin:
|
||||||
"""
|
"""
|
||||||
return cls.match.lower() in message
|
return cls.match.lower() in message
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def throw(cls):
|
|
||||||
"""
|
|
||||||
Throw error
|
|
||||||
|
|
||||||
:raise: this
|
|
||||||
"""
|
|
||||||
raise cls(cls.text or cls.match)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def detect(cls, description):
|
def detect(cls, description):
|
||||||
description = description.lower()
|
description = description.lower()
|
||||||
|
|
@ -107,7 +112,7 @@ class _MatchErrorMixin:
|
||||||
if err is cls:
|
if err is cls:
|
||||||
continue
|
continue
|
||||||
if err.check(description):
|
if err.check(description):
|
||||||
err.throw()
|
raise err(cls.text or description)
|
||||||
raise cls(description)
|
raise cls(description)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -164,6 +169,14 @@ class MessageTextIsEmpty(MessageError):
|
||||||
match = 'Message text is empty'
|
match = 'Message text is empty'
|
||||||
|
|
||||||
|
|
||||||
|
class MessageCantBeEdited(MessageError):
|
||||||
|
match = 'message can\'t be edited'
|
||||||
|
|
||||||
|
|
||||||
|
class MessageToEditNotFound(MessageError):
|
||||||
|
match = 'message to edit not found'
|
||||||
|
|
||||||
|
|
||||||
class ToMuchMessages(MessageError):
|
class ToMuchMessages(MessageError):
|
||||||
"""
|
"""
|
||||||
Will be raised when you try to send media group with more than 10 items.
|
Will be raised when you try to send media group with more than 10 items.
|
||||||
|
|
@ -171,10 +184,22 @@ class ToMuchMessages(MessageError):
|
||||||
match = 'Too much messages to send as an album'
|
match = 'Too much messages to send as an album'
|
||||||
|
|
||||||
|
|
||||||
|
class ObjectExpectedAsReplyMarkup(BadRequest):
|
||||||
|
match = 'object expected as reply markup'
|
||||||
|
|
||||||
|
|
||||||
|
class InlineKeyboardExpected(BadRequest):
|
||||||
|
match = 'inline keyboard expected'
|
||||||
|
|
||||||
|
|
||||||
class ChatNotFound(BadRequest):
|
class ChatNotFound(BadRequest):
|
||||||
match = 'chat not found'
|
match = 'chat not found'
|
||||||
|
|
||||||
|
|
||||||
|
class ChatDescriptionIsNotModified(BadRequest):
|
||||||
|
match = 'chat description is not modified'
|
||||||
|
|
||||||
|
|
||||||
class InvalidQueryID(BadRequest):
|
class InvalidQueryID(BadRequest):
|
||||||
match = 'QUERY_ID_INVALID'
|
match = 'QUERY_ID_INVALID'
|
||||||
text = 'Invalid query ID'
|
text = 'Invalid query ID'
|
||||||
|
|
@ -228,11 +253,23 @@ class InvalidStickersSet(BadRequest):
|
||||||
text = 'Stickers set is invalid'
|
text = 'Stickers set is invalid'
|
||||||
|
|
||||||
|
|
||||||
|
class NoStickerInRequest(BadRequest):
|
||||||
|
match = 'there is no sticker in the request'
|
||||||
|
|
||||||
|
|
||||||
class ChatAdminRequired(BadRequest):
|
class ChatAdminRequired(BadRequest):
|
||||||
match = 'CHAT_ADMIN_REQUIRED'
|
match = 'CHAT_ADMIN_REQUIRED'
|
||||||
text = 'Admin permissions is required!'
|
text = 'Admin permissions is required!'
|
||||||
|
|
||||||
|
|
||||||
|
class NotEnoughRightsToPinMessage(BadRequest):
|
||||||
|
match = 'not enough rights to pin a message'
|
||||||
|
|
||||||
|
|
||||||
|
class CantDemoteChatCreator(BadRequest):
|
||||||
|
match = 'can\'t demote chat creator'
|
||||||
|
|
||||||
|
|
||||||
class CantRestrictSelf(BadRequest):
|
class CantRestrictSelf(BadRequest):
|
||||||
match = "can't restrict self"
|
match = "can't restrict self"
|
||||||
text = "Admin can't restrict self."
|
text = "Admin can't restrict self."
|
||||||
|
|
@ -251,6 +288,20 @@ class TypeOfFileMismatch(BadRequest):
|
||||||
match = 'type of file mismatch'
|
match = 'type of file mismatch'
|
||||||
|
|
||||||
|
|
||||||
|
class WrongRemoteFileIdSpecified(BadRequest):
|
||||||
|
match = 'wrong remote file id specified'
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentProviderInvalid(BadRequest):
|
||||||
|
match = 'PAYMENT_PROVIDER_INVALID'
|
||||||
|
text = 'payment provider invalid'
|
||||||
|
|
||||||
|
|
||||||
|
class CurrencyTotalAmountInvalid(BadRequest):
|
||||||
|
match = 'currency_total_amount_invalid'
|
||||||
|
text = 'currency total amount invalid'
|
||||||
|
|
||||||
|
|
||||||
class BadWebhook(BadRequest):
|
class BadWebhook(BadRequest):
|
||||||
__group = True
|
__group = True
|
||||||
|
|
||||||
|
|
@ -274,6 +325,10 @@ class CantParseUrl(BadRequest):
|
||||||
match = 'can\'t parse URL'
|
match = 'can\'t parse URL'
|
||||||
|
|
||||||
|
|
||||||
|
class CantParseEntities(BadRequest):
|
||||||
|
match = 'can\'t parse entities'
|
||||||
|
|
||||||
|
|
||||||
class NotFound(TelegramAPIError, _MatchErrorMixin):
|
class NotFound(TelegramAPIError, _MatchErrorMixin):
|
||||||
__group = True
|
__group = True
|
||||||
|
|
||||||
|
|
@ -316,6 +371,10 @@ class CantInitiateConversation(Unauthorized):
|
||||||
match = 'bot can\'t initiate conversation with a user'
|
match = 'bot can\'t initiate conversation with a user'
|
||||||
|
|
||||||
|
|
||||||
|
class CantTalkWithBots(Unauthorized):
|
||||||
|
match = 'bot can\'t send messages to bots'
|
||||||
|
|
||||||
|
|
||||||
class NetworkError(TelegramAPIError):
|
class NetworkError(TelegramAPIError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue