-
Notifications
You must be signed in to change notification settings - Fork 408
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
Improve errors [SDK-3552] #782
Merged
Merged
Conversation
This file contains 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
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
bf29ee4
to
96adbc9
Compare
96adbc9
to
91c83de
Compare
adamjmcgrath
approved these changes
Aug 17, 2022
This was referenced Oct 5, 2022
Merged
Merged
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.
📋 Changes
This PR reworks the SDK errors to:
Underlying errors
Now, SDK errors can inherit from the base
AuthError
, which contains acause?
property for an underlying error. This way, errors can wrap another error simply by populating this property. The message of the 'wrapped' error will be automatically appended to the message of the 'wrapper' error (and labeled accordingly), which makes it easily discoverable and actionable by the developer.Error codes
SDK errors that inherit from
AuthError
will need to specify a machine-readablecode
. Developers can rely on error codes to identify specific errors. Unlike error messages, codes are part of the SDK API and will remain stable within a major version of the SDK. The error codes follow theERR_SOMETHING
Node.js convention.Error names
SDK errors that inherit from
AuthError
will need to specify a value for thename
property (typically the error class name). This value will show up when printing an error withconsole.log(error)
, making it easier for the developer to identify the error.API handler-specific errors
Before,
HandlerError
was the single catch-all error for all errors produced by an API handler. Now every handler has its own error:CallbackHandlerError
for the errors of the callback handlerLoginHandlerError
for the errors of the login handlerLogoutHandlerError
for the errors of the logout handlerProfileHandlerError
for the errors of the profile handlerThis makes it possible for handler-specific errors to feature handler-specific codes. The end result is that every handler will only throw errors of a single type, with a machine-readable code, and a single wrapped error. Which greatly simplifies error handling.