From 5868f20cab24007a98d1c276325c46c259ce8122 Mon Sep 17 00:00:00 2001 From: Conor H Date: Wed, 9 Aug 2017 22:21:55 +0200 Subject: [PATCH] Fix secondary error when handing errors. Not all errors are guaranteed to have a code. Setting status to an undefined code is itself another error which masks the original error. --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1ab2b9a..c25ef2f 100644 --- a/index.js +++ b/index.js @@ -156,7 +156,9 @@ var handleError = function(e, req, res, response, next) { res.set(response.headers); } - res.status(e.code); + if (e.code) { + res.status(e.code); + } if (e instanceof UnauthorizedRequestError) { return res.send();