Skip to content

Commit 79d7779

Browse files
committed
prevent invalid status codes from being sent on error
1 parent 9582469 commit 79d7779

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libs/response-extensions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module.exports.send = (options, req, res) => (data = 200, code = 200, headers =
2323
data = res.body
2424
} else if (data instanceof Error) {
2525
// transparently supporting Error instances
26-
code = data.status || data.code || 500
26+
const errorCode = data.status || data.code || data.statusCode
27+
code = typeof errorCode === 'number' ? parseInt(errorCode) : 500
2728
data = {
2829
errClass: data.constructor.name,
2930
code,

0 commit comments

Comments
 (0)