This class represents errors that are thrown by Opengram because the Telegram Bot API responded with an error. Instances of this class hold the information that the Telegram backend returned. If this error is thrown, Opengram could successfully communicate with the Telegram Bot API servers, however, an error code was returned for the respective method call.

You can check is error belongs to TelegramError by using isTelegramError

Also, Opengram provides exception's classes for most Bots API errors, you can use it to discriminate exceptions.


const { Exceptions, TelegramError } = require('opengram')
// ...
// error = 400: Bad Request: message is too long
console.log(err instanceof TelegramError) // true
console.log(err instanceof Exceptions.BadRequest) // true
console.log(err instanceof Exceptions.MessageIsTooLong) // true

You can find available exceptions classes here - Exceptions