Skip to content

Commit

Permalink
Merge pull request #52 from thebayesianconspiracy/error-handling
Browse files Browse the repository at this point in the history
Add error handling to sendPhoto
  • Loading branch information
sam17 authored Apr 7, 2024
2 parents d0dd23f + a286b6d commit 9787b36
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions telegram_bot/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,19 @@ function printGraph(
"," +
maximum;
console.log(url);
ctx.replyWithPhoto({
url: url
// ctx.replyWithPhoto({
// url: url
// });
ctx.replyWithPhoto({ url: url }).catch(error => {
console.error("Failed to send photo:", error);
if (error.response && error.response.status === 502) {
console.log(
"Sorry, there was a problem generating the graph. Please try again later."
);
} else {
// Handle other errors or rethrow them
console.log("An unexpected error occurred. Please try again.");
}
});
}

Expand Down

0 comments on commit 9787b36

Please sign in to comment.