feat: error handling on ticks#861
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. |
sheerlox
left a comment
There was a problem hiding this comment.
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! |
|
🎉 This PR is included in version 3.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [3.4.0](v3.3.2...v3.4.0) (2025-01-09) ### ✨ Features * error handling on ticks ([#861](#861)) ([0d3161f](0d3161f)), closes [#426](#426) ### 📚 Documentation * **contributing:** add "Submitting a Pull Request" & "Coding Rules" sections ([#936](#936)) ([ddd8988](ddd8988)) ### ♻️ Chores * **deps:** lock file maintenance ([494b4bf](494b4bf)) * **deps:** update dependency [@types](https://github.com/types)/node to v20.17.11 ([2978e92](2978e92)) * **deps:** update dependency lint-staged to v15.3.0 ([11f9bad](11f9bad)) * **deps:** update semantic-release related packages ([b830bdb](b830bdb)) * **deps:** update tests (major) ([#826](#826)) ([e47fd5a](e47fd5a))
Description
I've added an error handling method in the
CronJobclass and added it to the constructors parameters. This error handling method will be called if any exception is thrown from theonTickmethod. 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
onTickmethod 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 providedScreenshots (if appropriate):
Types of changes
Checklist:
!after the type/scope in the title (see the Conventional Commits standard).