My project is configured with typescipt and open-api 3 specification.
I try to optimize my error handling, but the err parameter in the errorMiddleware is a plain js object.
Because of this, it is very hard or partly not possible to know, if the error is a validation error from openapi or another error.
It would be better, if the err has a specific type and not only is a object.
The type checking of the err could be something like this:
if (err instanceOf ValidationError) {}
initialize({ ... errorMiddleware: (err, req, res, next) => { ... } });
My project is configured with typescipt and open-api 3 specification. I try to optimize my error handling, but the
err
parameter in the errorMiddleware is a plain js object. Because of this, it is very hard or partly not possible to know, if the error is a validation error from openapi or another error. It would be better, if theerr
has a specific type and not only is a object.The type checking of the
err
could be something like this:if (err instanceOf ValidationError) {}
I found this on your project: https://github.com/kogosoftwarellc/open-api/blob/master/packages/openapi-request-validator/index.ts#L382 , I think this can be optimized there.