May 2018
Intermediate to advanced
492 pages
12h 3m
English
Uncaught exceptions is another area where important information can be lost. This is easy to fix in the Notes application:
const error = require('debug')('notes:error'); process.on('uncaughtException', function(err) { error("I've crashed!!! - "+ (err.stack || err)); }); .. if (app.get('env') === 'development') { app.use(function(err, req, res, next) { // util.log(err.message); res.status(err.status || 500); error((err.status || 500) +' '+ error.message); res.render('error', { message: err.message, error: err }); }); } .. app.use(function(err, req, res, next) { // util.log(err.message); res.status(err.status || 500); error((err.status || 500) +' '+ error.message); res.render('error', { message: err.message, error: {} }); ...Read now
Unlock full access