# 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.

  __firstlineno__ = 99
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

exception telethon.errors.common.AuthKeyNotFound

  Bases: `Exception`

  The server claims it doesn’t know about the authorization key (session file) currently being used. This might be because it either has never seen this authorization key, or it used to know about the authorization key but has forgotten it, either temporarily or permanently (possibly due to server errors).

  If the issue persists, you may need to recreate the session file and login again. This is not done automatically because it is not possible to know if the issue is temporary or permanent.

  __firstlineno__ = 62
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

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.'}
  __firstlineno__ = 110
  __static_attributes__ = ('code',)
  __weakref__

    list of weak references to the object

exception telethon.errors.common.CdnFileTamperedError

  Bases: `SecurityError`

  Occurs when there’s a hash mismatch between the decrypted CDN file and its expected hash.

  __firstlineno__ = 88
  __static_attributes__ = ()

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

  __firstlineno__ = 45
  __static_attributes__ = ('code', 'payload')
  __weakref__

    list of weak references to the object

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.

  __firstlineno__ = 30
  __static_attributes__ = ('checksum', 'valid_checksum')
  __weakref__

    list of weak references to the object

exception telethon.errors.common.MultiError(exceptions, result, requests)

  Bases: `Exception`

  Exception container for multiple `TLRequest`’s.

  __firstlineno__ = 157
  static __new__(cls, exceptions, result, requests)
  __static_attributes__ = ('exceptions', 'requests', 'results')
  __weakref__

    list of weak references to the object

exception telethon.errors.common.ReadCancelledError

  Bases: `Exception`

  Occurs when a read operation was cancelled.

  __firstlineno__ = 8
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

exception telethon.errors.common.SecurityError(*args)

  Bases: `Exception`

  Generic security error, mostly used when generating a new AuthKey.

  __annotations__ = {}
  __firstlineno__ = 78
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

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.

  __firstlineno__ = 14
  __static_attributes__ = ('invalid_constructor_id', 'remaining')
  __weakref__

    list of weak references to the object