Open nicoandreoli2000 opened 6 months ago
@Aquila169 I can help you with the implementation, we just need to change the functions sendError
and sendErrors
:
export const sendErrors: (errors: Array<ErrorListItem>, res: Response) => void = (errors, res) => {
throw new CustomError(...)
};
export const sendError: (error: ErrorListItem, res: Response) => void = (error, res) => {
throw new CustomError(...)
};
I was also having troubles with this approach, my errorHandler was not catching errors and I was constantly getting can not set headers after they are sent to the client errors
Description
When a validation fails, the library does this:
res.status(400).send(...)
When it should actually do this:
throw new ZodError(...)
If not, there's no way of parsing the errors to match different needs.