Errors
Every failure throws, or rejects with, a JavaScript Error whose code names it.
OT_<CODE>: a failure of the core.codeisOT_followed by the core’s stable code,messageis the core’s human-readable text, andlegacyMessageis the message of the matching Python exception; anOT_error without one, such as an SRP refusal, repeatsmessagethere.ERR_INVALID_ARG_VALUE: an argument the binding rejects before the core sees it, such as an unknown client name or a wrongly typed patch; it has nolegacyMessage.
errors.mjs
import { loadTdata } from 'opentele2'
try {
await loadTdata('tdata', 'wrong passcode')
} catch (error) {
if (error.code === 'OT_TDATA_BAD_DECRYPT_KEY') console.log('wrong or missing passcode')
else if (error.code === 'OT_TFILE_NOT_FOUND') console.log(error.legacyMessage) // Could not open key_data
else throw error
}code values are stable across releases; message may change, so match on code. Each row
below names the exception the Python package raises for the same failure.
Core codes
code | Raised when |
|---|---|
OT_TFILE_NOT_FOUND | A required tdata file or .session file does not exist. Python: TFileNotFound. |
OT_TDATA_INVALID_MAGIC | A tdata file does not start with TDF$, or the MTP data holds an unknown block. Python: TDataInvalidMagic. |
OT_ | A tdata file’s MD5 checksum does not match its contents. Python: TDataInvalidCheckSum. |
OT_ | Decryption does not match its key: the passcode is missing or wrong. Python: TDataBadDecryptKey. |
OT_ | The local passcode does not unlock the folder. Python: TDataWrongPasscode. |
OT_ | Encrypted data has a size AES-IGE cannot take. Python: TData. |
OT_ | Decrypted data declares a size that does not fit. Python: TData. |
OT_ | An MTP config, endpoint or session row does not parse, or the main DC has no endpoint. Python: TDataBadConfigData. |
OT_QDATASTREAM_FAILED | A Qt data stream read failed, or a .session file has another layout or version. Python: QDataStreamFailed. |
OT_ | An account’s maps file cannot be read. Python: TDataReadMapDataFailed. |
OT_ | An account’s map was read with a wrong passcode. Python: TData. |
OT_ | No auth key for the main DC, or no row or key in a .session file. Python: TDataAuthKeyNotFound. |
OT_MAX_ACCOUNT_LIMIT | A folder would hold more accounts than it may. Python: MaxAccountLimit. |
OT_TDATA_SAVE_FAILED | Saving failed: no accounts, duplicate indices or an empty key file name. Python: TDataSaveFailed. |
OT_ | The key file is malformed or its passcode wrap parameters are unusable. Python: TDataKeyDataInvalid. |
OT_BAD_LENGTH | A buffer, key or IV has the wrong length. Python: ValueError. |
OT_INVALID_INPUT | An argument is outside what the operation accepts. Python: ValueError. |
OT_IO | A file operation failed, or data is not what it should be (gzip, session JSON). Python: OSError. |
Flow and SRP codes
The client flows of opentele2/mtcute and srpCheck fail with these;
the name of a flow error is its Python exception class.
code | Raised when |
|---|---|
OT_ | A QR login met 2FA without a password. Python: NoPasswordProvided. |
OT_PASSWORD_INCORRECT | auth.checkPassword failed with PASSWORD_HASH_INVALID. Python: PasswordIncorrect. |
OT_ | The QR login token was accepted already. Python: Auth. |
OT_AUTH_TOKEN_EXPIRED | The QR login token expired. Python: AuthTokenExpiredError. |
OT_AUTH_TOKEN_INVALID | The QR login token is invalid. Python: AuthTokenInvalidError. |
OT_QR_LOGIN_TIMEOUT | No QR login attempt logged in. Python: TimeoutError. |
OT_ | A session cannot be terminated within 24 hours of login. Python: Fresh. |
OT_HASH_INVALID | terminateSession was given an unknown hash. Python: HashInvalidError. |
OT_ | The 2FA password uses an algorithm other than SRP_ALGORITHM. Python: ValueError. |
OT_SIGN_UP_REQUIRED | The server asked to sign up instead of logging in. Python: SignUpRequired. |
OT_USER_ID_UNRESOLVED | The self user of a client cannot be resolved. Python: TelethonUnauthorized. |
OT_ | The account’s sessions cannot be fetched. Python: OpenTeleException. |
OT_ | The 2FA p or g is not acceptable. Python: ValueError. |
OT_SRP_BAD_B | The server’s srpB is out of range or missing. Python: ValueError. |
OT_SRP_NO_GOOD_RANDOM | Every random draw for the SRP exponent was unusable. Python: ValueError. |
OT_ | The OS random source failed during the SRP check. Python: ValueError. |
index.d.ts
function flowErrorClasses(): Record<string, string>flowErrorClasses() returns the Python class name of every flow and SRP code above, by OT_ code.
Last updated on