API Errors
These are the base errors that Telegram’s API may raise.
See RPC Errors for a more in-depth explanation on how to handle all known possible errors and learning to determine what a method may raise.
Errors not related to the Telegram API itself
- exception telethon.errors.common.AlreadyInConversationError
Bases:
Exception
Occurs when another exclusive conversation is opened in the same chat.
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.BadMessageError(request, code)
Bases:
Exception
Occurs when handling a bad_message_notification.
- ErrorMessages = {16: 'msg_id too low (most likely, client time is wrong it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the "correct" msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted).', 17: 'msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id).', 18: 'Incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4).', 19: 'Container msg_id is the same as msg_id of a previously received message (this must never happen).', 20: 'Message too old, and it cannot be verified whether the server has received a message with this msg_id or not.', 32: 'msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno).', 33: 'msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno).', 34: 'An even msg_seqno expected (irrelevant message), but odd received.', 35: 'Odd msg_seqno expected (relevant message), but even received.', 48: 'Incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it).', 64: 'Invalid container.'}
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.CdnFileTamperedError
Bases:
telethon.errors.common.SecurityError
Occurs when there’s a hash mismatch between the decrypted CDN file and its expected hash.
- exception telethon.errors.common.InvalidBufferError(payload)
Bases:
BufferError
Occurs when the buffer is invalid, and may contain an HTTP error code. For instance, 404 means “forgotten/broken authorization key”, while
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.InvalidChecksumError(checksum, valid_checksum)
Bases:
Exception
Occurs when using the TCP full mode and the checksum of a received packet doesn’t match the expected checksum.
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.MultiError(exceptions, result, requests)
Bases:
Exception
Exception container for multiple
TLRequest
’s.- static __new__(cls, exceptions, result, requests)
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.ReadCancelledError
Bases:
Exception
Occurs when a read operation was cancelled.
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.SecurityError(*args)
Bases:
Exception
Generic security error, mostly used when generating a new AuthKey.
- __annotations__ = {}
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.common.TypeNotFoundError(invalid_constructor_id, remaining)
Bases:
Exception
Occurs when a type is not found, for example, when trying to read a TLObject with an invalid constructor code.
- __weakref__
list of weak references to the object (if defined)
- exception telethon.errors.rpcbaseerrors.AuthKeyError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
Errors related to invalid authorization key, like AUTH_KEY_DUPLICATED which can cause the connection to fail.
- code = 406
- message = 'AUTH_KEY'
- exception telethon.errors.rpcbaseerrors.BadRequestError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
The query contains errors. In the event that a request was created using a form and contains user generated data, the user should be notified that the data must be corrected before the query is repeated.
- __annotations__ = {}
- code = 400
- message = 'BAD_REQUEST'
- telethon.errors.rpcbaseerrors.BotTimeout
- exception telethon.errors.rpcbaseerrors.FloodError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
The maximum allowed number of attempts to invoke the given method with the given input parameters has been exceeded. For example, in an attempt to request a large number of text messages (SMS) for the same phone number.
- __annotations__ = {}
- code = 420
- message = 'FLOOD'
- exception telethon.errors.rpcbaseerrors.ForbiddenError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
Privacy violation. For example, an attempt to write a message to someone who has blacklisted the current user.
- __annotations__ = {}
- code = 403
- message = 'FORBIDDEN'
- exception telethon.errors.rpcbaseerrors.InvalidDCError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
The request must be repeated, but directed to a different data center.
- __annotations__ = {}
- code = 303
- message = 'ERROR_SEE_OTHER'
- exception telethon.errors.rpcbaseerrors.NotFoundError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
An attempt to invoke a non-existent object, such as a method.
- __annotations__ = {}
- code = 404
- message = 'NOT_FOUND'
- exception telethon.errors.rpcbaseerrors.RPCError(request, message, code=None)
Bases:
Exception
Base class for all Remote Procedure Call errors.
- __annotations__ = {}
- __reduce__()
Helper for pickle.
- __weakref__
list of weak references to the object (if defined)
- code = None
- message = None
- exception telethon.errors.rpcbaseerrors.ServerError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
An internal server error occurred while a request was being processed for example, there was a disruption while accessing a database or file storage.
- __annotations__ = {}
- code = 500
- message = 'INTERNAL'
- exception telethon.errors.rpcbaseerrors.TimedOutError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
Clicking the inline buttons of bots that never (or take to long to) call
answerCallbackQuery
will result in this “special” RPCError.- __annotations__ = {}
- code = 503
- message = 'Timeout'
- exception telethon.errors.rpcbaseerrors.UnauthorizedError(request, message, code=None)
Bases:
telethon.errors.rpcbaseerrors.RPCError
There was an unauthorized attempt to use functionality available only to authorized users.
- __annotations__ = {}
- code = 401
- message = 'UNAUTHORIZED'