-
Notifications
You must be signed in to change notification settings - Fork 157
improv(batch): improve errors #1648
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
Conversation
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.
I like the idea of the errors here, and I had some time to check in, so I thought I'd leave some comments! Feel free to let me know your thoughts.
super(msg); | ||
this.msg = msg; | ||
this.childErrors = childErrors; | ||
class BatchProcessingError extends Error { |
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.
Would we want the error thrown in the BatchProcessor
here to be as this BatchProcessingError
instead of just Error
, now that we have this?
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.
Indeed, very good catch. Updated in the latest commit.
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.
Do we want a test or two to check the contents of errors?
Same for the SQS FIFO processor class, we don't have anything that actually checks the error name, message, etc, of the error thrown.
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.
I think it's a good point, I have updated the SQSFifo & other tests to at least test the error type.
For now we'll leave the Error contents out of the tests to avoid making them too rigid.
Kudos, SonarCloud Quality Gate passed!
|
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.
Do we want to update the error passed to the failure handler here (and in AsyncBatchProcessor
) to be the BatchProcessingError
as well?
And potentially add tests for the error type checking like with the SqsFifoPartialProcessor
tests if we add the typing here?
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.
I think we should leave Error
there because that's the type expected by failureHandler
and we want that method to stay generic so that customers creating their own partial processor can pass any type of error. Making the error more strict would force them to have to subclass our own error class.
Description of your changes
This PR improves the implementation of the errors thrown by the Batch Processing utility as well as some of the outputs by streamlining the log emitted or adding names to the errors and establishing a hierarchy.
Most of the errors were either using a generic
Error
class and/or expecting the caller to do the heavy-lifting of formatting the message. This PR introduces errors classes that are thrown in specific cases, which will help customers withtry/catch
logic.Additionally, in most cases the errors are now performing the formatting or including the message/name that defines them without the caller having to specify it.
Related issues, RFCs
Issue number: closes #1647
Checklist
Breaking change checklist
Is it a breaking change?: NO
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.