From cdbfa96426fd0ea24de6758497bc3b97929cd268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Tue, 20 Feb 2018 10:25:54 +0100 Subject: [PATCH] fix(errors): only remove stack from error in production --- app.js | 5 ++++- views/error.pug | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 2a0df78..45e5afa 100644 --- a/app.js +++ b/app.js @@ -149,8 +149,11 @@ app.use(function (request, response, next) { // Error handler app.use(function (err, request, response, next) { // Set locals, only providing error in development - response.locals.error = request.app.get('env') === 'development' ? err : {} + response.locals.error = err response.locals.error.status = err.status || 500 + if (request.app.get('env') !== 'development') { + delete err.stack + } response.locals.title = 'Error' // Render the error page response.status(err.status || 500) diff --git a/views/error.pug b/views/error.pug index af46fdc..d38aadb 100644 --- a/views/error.pug +++ b/views/error.pug @@ -4,7 +4,7 @@ block content .layout-centered .error h1 #{translate('somethingWentWrongLabel', currentLocale.code)} (#{error.status}) - // We use the last line to have a human readable output for pug error messages + //- We use the last line to have a human readable output for pug error messages p #{error.message.split('\n').pop()} h2 #{translate('hintsLabel', currentLocale.code)}