Replies: 1 comment
-
I guess it's possible to do this throw json({
message: 'Validation error',
errors: error.errors,
}, { status: 400 }) But |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Would it be possible to throw errors in server functions / middlewares along with a custom status code instead of systematically respond with a 500 code. For clarity and documentation, always returning a 500 seems a bit strange.
If not that, why can't we abort a request within a middleware by returning a custom response instead of the response from
await next()
?In particular, as an example, it would be nice to have a middleware that catches ZodErrors to respond with a 400 and a body containing the validation errors.
Beta Was this translation helpful? Give feedback.
All reactions