Skip to content

Commit

Permalink
Pass error to the response function
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdee committed Apr 18, 2019
1 parent 5d2b5b8 commit 08c0dbf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ function format(data) {
}
});

formatted[response].code = `return global.response(req, res, ${formatted[response].status}, ${inspect(responseObject, { showHidden: false, depth: null })});`;
const isErr = formatted[response].status >= 400 ? 'err' : 'null';
formatted[response].code = 'return global.response(req, res, '
+ `${formatted[response].status}, ${inspect(responseObject, { showHidden: false, depth: null })}, ${isErr});`;
});

// add the code to the resulting object
Expand Down

0 comments on commit 08c0dbf

Please sign in to comment.