From 0a637752e36c755e5908887ff5115cdcf2d0419b Mon Sep 17 00:00:00 2001 From: Rowan Manning Date: Fri, 27 Sep 2013 15:24:48 +0100 Subject: [PATCH] Add better error stacks to the log --- app.js | 3 +++ index.js | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index d93de6c..037eebc 100644 --- a/app.js +++ b/app.js @@ -65,6 +65,9 @@ function initApp (config, callback) { }); app.express.use(function (err, req, res, next) { /* jshint unused: false */ + if (err.code === 'ECONNREFUSED') { + err = new Error('Could not connect to pa11y-webservice'); + } app.emit('route-error', err); if (process.env.NODE_ENV !== 'production') { res.locals.error = err; diff --git a/index.js b/index.js index 20c37a5..8a48f2d 100644 --- a/index.js +++ b/index.js @@ -11,9 +11,11 @@ require('./app')(config, function (err, app) { console.log(chalk.grey('uri: %s'), app.address); app.on('route-error', function (err) { - if (err.code === 'ECONNREFUSED') { - console.log(chalk.red('Error: could not connect to pa11y-webservice')); - } + var stack = (err.stack ? err.stack.split('\n') : [err.message]); + var msg = chalk.red(stack.shift()); + console.error(''); + console.error(msg); + console.error(chalk.grey(stack.join('\n'))); }); });