mirror of https://github.com/pelias/api.git
Harish Krishna
10 years ago
1 changed files with 5 additions and 2 deletions
@ -1,9 +1,12 @@
|
||||
var logger = require( '../src/logger' ); |
||||
|
||||
// handle application errors
|
||||
function middleware(err, req, res, next) { |
||||
logger.error( 'Error:', err ); |
||||
logger.error( 'Stack trace:', err.trace ); |
||||
res.header('Cache-Control','no-cache'); |
||||
if( res.statusCode < 400 ){ res.status(500); } |
||||
res.json({ error: err }); |
||||
res.json({ error: 'internal server error' }); |
||||
} |
||||
|
||||
module.exports = middleware; |
||||
module.exports = middleware; |
||||
|
Loading…
Reference in new issue