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

PIMS-1472 Controller Error Wrapper #2266

Merged
merged 7 commits into from
Mar 21, 2024
Merged

Conversation

dbarkowsky
Copy link
Collaborator

@dbarkowsky dbarkowsky commented Mar 20, 2024

🎯 Summary

PIMS-1472

This wrapper, when placed around a controller, ensures that any thrown errors are caught and passed to the generic error handler. No more reason to wrap the internal implementation of individual controllers in try/catch blocks unless you want to send a specific status/code. Consider this a fallback option when we fail to handle errors uniquely.

Changes

  • Added catchError function (thanks @GrahamS-Quartech for the initial code)
  • Added this function to all existing controllers in routes files
  • Updated controllers to reflect this change (mostly removing try/catch where it only returns default code/message)
  • Updated tests to match

🔰 Checklist

  • I have read and agree with the following checklist and am following the guidelines in our Code of Conduct document.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation where required.
  • I have tested my changes to the best of my ability.
  • My changes generate no new warnings.

Copy link

🚀 Deployment Information

The Express API Image has been built with the tag: 2266. Please make sure to utilize this specific tag when promoting these changes to the TEST and PROD environments during the API deployment. For more updates please monitor Image Tags Page on Wiki.

Copy link

codeclimate bot commented Mar 20, 2024

Code Climate has analyzed commit c069138 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 96.9% (50% is the threshold).

This pull request will bring the total coverage in the repository to 94.9%.

View more on Code Climate.

@dbarkowsky dbarkowsky merged commit 78f1eca into main Mar 21, 2024
5 checks passed
@dbarkowsky dbarkowsky deleted the PIMS-1472-Controller-Error-Wrapper branch March 21, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants