Browse Source

Merge pull request #116 from pelias/runtime-error-reporting#114

Resolve #114: report runtime errors.
pull/93/merge
Harish Krishna 10 years ago
parent
commit
e1ddcbb93f
  1. 7
      middleware/500.js

7
middleware/500.js

@ -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…
Cancel
Save