-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
🔧 Fix local error handler #970
Conversation
const getLocalError = (response: unknown, hookError: HookContainer[]): Result | undefined => { | ||
if (response instanceof ElysiaCustomStatusResponse) { |
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.
Can we be sure that whenever response
is an ElysiaCustomStatusResponse
it means an error?
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.
yes, ElysiaCustomStatusResponse
is only return from Elysia.error
@@ -272,4 +272,84 @@ describe('error', () => { | |||
somePretty: 'json' | |||
}) | |||
}) | |||
|
|||
describe('handle scoped error', async () => { |
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.
@SaltyAom Please, can you confirm if these tests define the expected behavior when handling locally the error?
@@ -272,4 +272,84 @@ describe('error', () => { | |||
somePretty: 'json' | |||
}) | |||
}) | |||
|
|||
describe('handle scoped error', async () => { |
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.
@SaltyAom If an exception is thrown, how should be the behavior? Should be the same as calling error
, or should it go directly to the global error handler (i.e., onError
)?
Currently, is the latter: it goes directly to the onError
.
BUT I think that the expected behavior is going to the local handler first.
Closing this PR, since the current behavior is working as intended. |
This PR fixes #966, following what's expected from the doc.
BUT it's still WIP because I started to wonder how is really the expected behavior.
I think there is something missing being defined, or even if the local error worked someday because I could find no test and there are too many missing pieces here.