mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-27 08:18:08 +03:00
791 B
791 B
id | title | sidebar_label | slug |
---|---|---|---|
error-handling | Error handling | Error handling | /error-handling |
By default, nestjs-telegraf
catches all errors using the Logger
built into NestJS.
Use can disable global errors catch with disableGlobalCatch
:
TelegrafModule.forRoot({
disableGlobalCatch: true,
}),
After that you can override errors handling with bot instance catch
function.
import { Injectable } from '@nestjs/common';
import { InjectBot, TelegrafProvider, Context } from 'nestjs-telegraf';
@Injectable()
export class BotSettingsService {
constructor(@InjectBot() private bot: TelegrafProvider<Context>) {
this.bot.catch((err, ctx) => {
console.log(`Ooops, encountered an error for ${ctx.updateType}`, err);
});
}
}