-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Error handler with context #158
Conversation
Codecov Report
@@ Coverage Diff @@
## master #158 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 4 4
Lines 147 144 -3
Branches 44 42 -2
=====================================
- Hits 147 144 -3
Continue to review full report at Codecov.
|
9ef198e
to
1f50f29
Compare
CHANGELOG.md
Outdated
- If your code relies on `error.context` or `error.code` you still can access the same variables using `errorHandler` option: | ||
```js | ||
errorHandler(error, context) { | ||
const code = error.message === 'Route not found' ? 404 : 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking the message string feels dirty. How about a 3rd arg for the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to use a special route with (.*)
path for not found errors. This example just shows how easy to reach a backward compatibility. Maybe need to mention it, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree on the special route and would put that in the docs. I wouldn't encourage the string check and explicitly mention it's for backwards compat.
ff9f268
to
a7757c4
Compare
a7757c4
to
b61f561
Compare
The router no longer mutate errors to avoid issues with non-extensible objects.
If your code relies on
error.context
orerror.code
you still can access the same variables usingerrorHandler
option:Types of changes
Checklist:
Closes #152
Closes #154
Closes #156