Browse Source

err & err.message instead of err.message

pull/163/head
Harish Krishna 10 years ago
parent
commit
b3f85ebc17
  1. 2
      middleware/408.js
  2. 3
      middleware/500.js

2
middleware/408.js

@ -2,7 +2,7 @@
// handle time out errors
function middleware(err, req, res, next) {
res.header('Cache-Control','no-cache');
var error = err.message ? err.message : err;
var error = (err && err.message) ? err.message : err;
if( res.statusCode === 408 || (error.toLowerCase().indexOf('request timeout') !== -1) ){
res.status(408);

3
middleware/500.js

@ -4,7 +4,8 @@ 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.message ? err.message : err;
var error = (err && err.message) ? err.message : err;
if( res.statusCode < 400 ){ res.status(500); }
res.json({ error: typeof error === 'string' ? error : 'internal server error' });
}

Loading…
Cancel
Save