|
|
|
@ -4,8 +4,10 @@ var logger = require( 'pelias-logger' ).get( 'middleware-500' );
|
|
|
|
|
function middleware(err, req, res, next) { |
|
|
|
|
logger.error( 'Error: `%s`. Stack trace: `%s`.', err, err.stack ); |
|
|
|
|
res.header('Cache-Control','no-cache'); |
|
|
|
|
var error = (err && err.message) ? err.message : err; |
|
|
|
|
|
|
|
|
|
if( res.statusCode < 400 ){ res.status(500); } |
|
|
|
|
res.json({ error: err && typeof err.message === 'string' ? err.message : 'internal server error' }); |
|
|
|
|
res.json({ error: typeof error === 'string' ? error : 'internal server error' }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
module.exports = middleware; |
|
|
|
|