Skip to content

Initialize custom exception handling#1204

Open
cj-young wants to merge 4 commits into
ucfopen:devfrom
cj-young:issue/1203-exception_handling_initialization
Open

Initialize custom exception handling#1204
cj-young wants to merge 4 commits into
ucfopen:devfrom
cj-young:issue/1203-exception_handling_initialization

Conversation

@cj-young

Copy link
Copy Markdown

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 details property of ApiException is intended to handle custom error info for more complex uses like form errors. The errorCode property 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, the message that is passed into the error is strictly used for debugging and will not be read by the end user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant