-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.ts
More file actions
22 lines (20 loc) · 743 Bytes
/
error.ts
File metadata and controls
22 lines (20 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as Sentry from "@sentry/bun";
import { bot } from "../config/bot";
export function registerErrorHandler(): void {
bot.catch((err) => {
const ctx = err.ctx;
console.error(`Error while handling update ${ctx.update.update_id}:`);
console.error("Error:", err.error);
Sentry.withScope((scope) => {
scope.setContext("telegram_update", {
update_id: ctx.update.update_id,
user_id: ctx.from?.id,
username: ctx.from?.username,
chat_id: ctx.chat?.id,
message_text: ctx.message?.text,
});
scope.setTag("bot", "telegram");
Sentry.captureException(err.error);
});
});
}