1
0
Fork 0

Allow passing an error to res.throw as reason

This commit is contained in:
Alan Plum 2016-04-20 18:10:57 +02:00
parent 05578e8fbf
commit 0529471cdc
No known key found for this signature in database
GPG Key ID: 8ED72A9A323B6EFD
1 changed files with 8 additions and 0 deletions

View File

@ -282,6 +282,14 @@ module.exports = class SyntheticResponse {
if (typeof status === 'string') {
status = statuses(status);
}
if (reason instanceof Error) {
const err = reason;
reason = err.message;
args = Object.extend({
cause: err,
errorNum: err.errorNum
}, args);
}
if (reason && typeof reason === 'object') {
args = reason;
reason = undefined;