Error parameter in express middleware #1907
-
In express, you can define middleware to handle errors with a fourth parameter
You can also define this middleware after all the routes as the last item in your express stack. With EZ API you can define express-style middleware, but it does not allow for the fourth |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
In |
Beta Was this translation helpful? Give feedback.
-
Related discussion |
Beta Was this translation helpful? Give feedback.
In
express-zod-api
that job is carried out by ResultHandler.The errors happened in endpoint handlers, middlewares, IO validation — will be handled by the ResultHandler assigned to the EndpointsFactory those endpoints produced at.
Parsing errors and
404
errors are handled by the ResultHandler assigned toerrorHandler
in your config (by default it'sdefaultResultHandler
), @brandonk3nt