Skip to content

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

Merged
merged 2 commits into from
Aug 8, 2023
Merged

improv(batch): improve errors #1648

merged 2 commits into from
Aug 8, 2023

Conversation

dreamorosi
Copy link
Contributor

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 with try/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

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my change is effective and works
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

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.

@dreamorosi dreamorosi requested a review from a team August 7, 2023 11:56
@dreamorosi dreamorosi self-assigned this Aug 7, 2023
@boring-cyborg boring-cyborg bot added batch This item relates to the Batch Processing Utility tests PRs that add or change tests labels Aug 7, 2023
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Aug 7, 2023
@github-actions github-actions bot added the enhancement PRs that introduce minor changes, usually to existing features label Aug 7, 2023
Copy link
Contributor

@erikayao93 erikayao93 left a 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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@dreamorosi dreamorosi requested a review from erikayao93 August 8, 2023 12:38
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@dreamorosi dreamorosi merged commit bf00d5b into main Aug 8, 2023
@dreamorosi dreamorosi deleted the improv/batch/errors branch August 8, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch This item relates to the Batch Processing Utility enhancement PRs that introduce minor changes, usually to existing features size/L PRs between 100-499 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: improve error handling
2 participants