diff --git a/middleware/500.js b/middleware/500.js index d73c5684..15846ce0 100644 --- a/middleware/500.js +++ b/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: err.toString() }); } -module.exports = middleware; \ No newline at end of file +module.exports = middleware;