telegramx.js

TelegramError

class

extends Error

Thrown when the Telegram Bot API responds with ok: false. Exposes the numeric error_code, the human-readable description, and any parameters Telegram returned (e.g. retry_after, migrate_to_chat_id).

Declaration

declare class TelegramError extends Error 

Properties

codeproperty#
readonly code: number;

Telegram's numeric error code (mirrors the HTTP status in most cases).

methodproperty#
readonly method: string;

The Bot API method that was called (e.g. sendMessage).

parametersproperty#
readonly parameters?: ResponseParameters;

Extra machine-readable information about the error, when present.

retryAfterproperty#
get retryAfter(): number | undefined;

Seconds to wait before retrying, when Telegram rate-limits the request (HTTP 429).

Methods

(constructor)constructor#
constructor(method: string, code: number, description: string, parameters?: ResponseParameters);

Constructs a new instance of the TelegramError class