Closed nadeemramsing closed 4 months ago
You can overrite error.status
or return a raw Response
object as a workaround:
.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.
set.status = 400
must either work or not be made accessible.
I gave you a workaround to make it work for you right away.
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).