mirror of https://github.com/pelias/api.git
Peter Johnson a.k.a. insertcoffee
9 years ago
8 changed files with 33 additions and 25 deletions
@ -0,0 +1,13 @@ |
|||||||
|
|
||||||
|
// handle time out errors
|
||||||
|
function middleware(err, req, res, next) { |
||||||
|
res.header('Cache-Control','no-cache'); |
||||||
|
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 { |
||||||
|
next(err); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = middleware; |
Loading…
Reference in new issue