-
Notifications
You must be signed in to change notification settings - Fork 246
Open
Description
Hello, right now I see that response codes for errors are hardcoded to the route. This can cause confusion when there is an internal error because the client thinks it is a bad request.
In addition, the error message does not serialize correctly when passing an Error object, which several other middlewares require.
I have locally hacked
exports.respondOrErr = function(res, errStatusCode, err, statusCode, content) {
if (err) {
exports.respond(res, err.statusCode || errStatusCode, err.message || err);
} else {
exports.respond(res, statusCode, content);
}
};
and then am passing an Error like so
var error = new Error(err);
error.statusCode = 500;
next(error);
Is this satisfactory/best practice? Didn't feel like making a pull request for such a minor change without knowing that the pattern was acceptable.
Thanks
Metadata
Metadata
Assignees
Labels
No labels