Skip to content

Commit 45ca094

Browse files
committed
[service] log all uncaught errors from express handler
1 parent 950b238 commit 45ca094

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

service/src/express.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ const authentication = AuthenticationInitializer.initialize(app, passport, provi
6565
// TODO: don't pass authentication to other routes, but enforce authentication ahead of adding route modules
6666
require('./routes')(app, { authentication });
6767

68+
// Express requires a 4 parameter function callback, do not remove unused next parameter
6869
// eslint-disable-next-line @typescript-eslint/no-unused-vars
69-
app.use(function(err, req, res, next) { // Express requires a 4 parameter function callback, dont' remove unused next parameter
70-
if (process.env.NODE_ENV !== 'test') {
71-
log.error(err.message);
72-
log.error(err.stack);
73-
}
70+
app.use(function(err, req, res, next) {
71+
72+
log.error('\n-----\nunhandled error during request\n', req.method, req.path, err, '\n-----')
7473

7574
const status = err.status || 500;
7675
let msg = status === 500 ? 'Internal server error, please contact MAGE administrator.' : err.message;

0 commit comments

Comments
 (0)