Initialize custom exception handling#1204
Open
cj-young wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Begins work on #1203
This starts work on a new approach to error handling in the backend. The goal is to eventually allow all errors to propagate to an exception event listener, which in turn will create a standardized error response. This takes the responsibility of creating error responses away from controllers. To handle errors, the source of an error (typically of a third-party service like MySQL or a network request) would be wrapped in a try/catch, and a custom error would be thrown in the catch block. After that, the error would propagate on its own and be caught by the error event listener, so no other handling is necessary.
In this PR, the abstract class that custom errors will extend from has been created as well as the listener to handle all errors. The
detailsproperty ofApiExceptionis intended to handle custom error info for more complex uses like form errors. TheerrorCodeproperty should be set to a unique identifier for the error type. This identifier will be used on the frontend to determine an error message (if a message is displayed). Because of this, themessagethat is passed into the error is strictly used for debugging and will not be read by the end user.