swagger-tools
swagger-tools copied to clipboard
suggestion: mark response validation errors
As input errors generate a different response code and are handled differently, make it easy to distinguish them from another by adding
err.responseValidation = true
to the error object.
This allows to simply do something like this:
if(err.failedValidation) {
if(err.responseValidation) {
res.statusCode = 500;
res.end("Internal Error");
} else {
res.statusCode = 400;
res.end("Input Error");
}
}
Well, you could check for the existence of the originalResponse property but I'm not sure that's publicized. Let me think.
this only works if the originalRespons is not undefined. been there done that :)
Any updates here? :)