From 1cfa76880b1ba3ca3bffc2eea72fc47d0f1cb5fe Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Tue, 14 Jul 2015 14:24:39 -0400 Subject: [PATCH] check for err message if it contains the words request timeout (because sometimes it comes back as a 500 even though it should be 408) --- middleware/408.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/408.js b/middleware/408.js index fd577fb2..2b2a7b8a 100644 --- a/middleware/408.js +++ b/middleware/408.js @@ -2,7 +2,7 @@ // handle time out errors function middleware(err, req, res, next) { res.header('Cache-Control','no-cache'); - if( res.statusCode === 408 ){ + if( res.statusCode === 408 || (err.message.toLowerCase().indexOf('request timeout') !== -1) ){ res.status(408); res.json({ error: err && typeof err.message === 'string' ? err.message : 'request time out' }); } else {