fix(errors): only remove stack from error in production
This commit is contained in:
committed by
Benedikt Rötsch
parent
c36d98e5bb
commit
cdbfa96426
5
app.js
5
app.js
@@ -149,8 +149,11 @@ app.use(function (request, response, next) {
|
|||||||
// Error handler
|
// Error handler
|
||||||
app.use(function (err, request, response, next) {
|
app.use(function (err, request, response, next) {
|
||||||
// Set locals, only providing error in development
|
// 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
|
response.locals.error.status = err.status || 500
|
||||||
|
if (request.app.get('env') !== 'development') {
|
||||||
|
delete err.stack
|
||||||
|
}
|
||||||
response.locals.title = 'Error'
|
response.locals.title = 'Error'
|
||||||
// Render the error page
|
// Render the error page
|
||||||
response.status(err.status || 500)
|
response.status(err.status || 500)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ block content
|
|||||||
.layout-centered
|
.layout-centered
|
||||||
.error
|
.error
|
||||||
h1 #{translate('somethingWentWrongLabel', currentLocale.code)} (#{error.status})
|
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()}
|
p #{error.message.split('\n').pop()}
|
||||||
|
|
||||||
h2 #{translate('hintsLabel', currentLocale.code)}
|
h2 #{translate('hintsLabel', currentLocale.code)}
|
||||||
|
|||||||
Reference in New Issue
Block a user