fix(errors): only remove stack from error in production

This commit is contained in:
Benedikt Rötsch
2018-02-20 10:25:54 +01:00
committed by Benedikt Rötsch
parent c36d98e5bb
commit cdbfa96426
2 changed files with 5 additions and 2 deletions

5
app.js
View File

@@ -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)

View File

@@ -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)}