-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
onError: For 'VALIDATION' type errors, status code change does not work (200 is always returned) #639
Labels
bug
Something isn't working
Comments
You can overrite .onError(({ code, error }) => {
if (code === "VALIDATION") {
// @ts-ignore
// error.status = 400;
return new Response(error.message, {
status: 400,
headers: { "Content-Type": "application/json" },
});
}
}) |
Thank you; I'll try that. |
Working perfectly; thank you. |
Please leave the issue open as it's a bug and needs to be fixed somehow.
I gave you a workaround to make it work for you right away. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Elysia.JS is running?
"version": "1.0.17"
What platform is your computer?
Linux 5.15.0-88-generic x86_64 x86_64
What steps can reproduce the bug?
What is the expected behavior?
Return error and 400 status code.
What do you see instead?
Error is returned but status code remains 200.
Additional information
In fact, logger (HoltLogger) says "unknown status":
In my case, setting status code and even return a value (e.g. "TEST") does not work; 200 and Validation Error by type lib is returned. Execution gets there (console.log inserted and called just before the setting of status and return).
The text was updated successfully, but these errors were encountered: