Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add possibility to catch errors with bot.catch on webhook #741

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

shevernitskiy
Copy link
Contributor

@shevernitskiy shevernitskiy commented Jan 16, 2025

This PR adds error handling with bot.catch for webhooks.

I have several questions:

  • Should we log to the console if no handler is set in case of webhook (in the case of a default handler)?
  • Is it necessary to extend the try scope to cover the cases of new Api, new Context, and this.botInfo === undefined? I remove try-catch on a higher level caller handleUpdates which is used on polling. The possible unwrapped errors just missed FATAL console.log

Closes #702

Copy link
Member

@KnorpelSenf KnorpelSenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are a breath of fresh air, you made an excellent observation about our ability to drop the whole FATAL error thing. Thank you!

I just have a tiny request about the assertion in the test:

shevernitskiy and others added 2 commits January 16, 2025 19:10
@shevernitskiy
Copy link
Contributor Author

this should work:)

Copy link
Member

@KnorpelSenf KnorpelSenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much!

@KnorpelSenf KnorpelSenf merged commit ea3c74f into grammyjs:v2 Jan 16, 2025
@shevernitskiy shevernitskiy deleted the catch-on-webhook branch January 16, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants