Skip to content

Commit

Permalink
Add non-enumerable keys to the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Nov 2, 2023
1 parent c21ec90 commit 9d04b27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion functions/lib/handle-error/handle-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ const reportErrorToTelegram = (error: unknown, env: unknown) => {
return;
}

const errorData = {
message: (error as Error)?.message,
name: (error as Error)?.name,
stack: (error as Error)?.stack,
...Object.getOwnPropertyNames(error),
}

const bot = new Bot(envSafe.data.BOT_ERROR_REPORTING_TOKEN);
return bot.api
.sendMessage(
envSafe.data.BOT_ERROR_REPORTING_USER_ID,
JSON.stringify(error, Object.getOwnPropertyNames(error)),
JSON.stringify(errorData, null, 2),
)
.catch((error) => console.error("Telegram error report failed:", error));
};
Expand Down

0 comments on commit 9d04b27

Please sign in to comment.