-
Notifications
You must be signed in to change notification settings - Fork 625
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: error handling on ticks #861
base: main
Are you sure you want to change the base?
Conversation
+ added error handling function param on a new constructor + added the function param on the static `from` method + caught the errors in the callback method
+ removed `@ts-expect-error line` bc it was throwing error itself
feat
: error handling on job.start()
job.start()
job.start()
job.start()
+ Instead of a new constructor, I added the `errorHandler` on every other constructor + removed the superflous if checks + added `errorHandler` on every `return new CronJob`
Hey @sheerlox, Thanks for the review. I've incorporated all the suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for your contribution @JosephVoid 🙌
b3902a9
to
f13aba2
Compare
job.start()
Hey, any news on this being merged into main? |
hello, I'm currently working on the |
I submitted a PR to this branch to fix the merge conflicts. @JosephVoid if you can merge it then this PR will be ready for a final review |
actually I think I submitted the PR to the wrong branch. new one here. if it works then it should show this merge conflict as fixed |
Excellent work @JosephVoid, thank you for taking on this feature request! Thanks @intcreator also for taking over the review 😄 |
Looks like the tests aren't passing, if someone wants to look into it so we can merge! |
Description
I've added an error handling method in the
CronJob
class and added it to the constructors parameters. This error handling method will be called if any exception is thrown from theonTick
method. Also added two new tests to confirm that it works.Related Issue
Closes #426.
Motivation and Context
If any kind of exception occurs from the
onTick
method the whole process stops currently. To solve this, this feature will allow users to pass their own error handler when exceptions occur.How Has This Been Tested?
Added two new test cases called
should catch errors if errorhandler is provided
&should throw errors if errorhandler is NOT provided
Screenshots (if appropriate):
Types of changes
Checklist:
!
after the type/scope in the title (see the Conventional Commits standard).