Fix logger error serializer when the exception stack is not set

This commit is contained in:
Jorge Tarrero 2020-09-09 11:29:32 +02:00
parent a121fd75ab
commit dc1becd15c

View File

@ -9,7 +9,9 @@ module.exports = class Logger {
const { LOG_LEVEL, NODE_ENV } = process.env; const { LOG_LEVEL, NODE_ENV } = process.env;
const logLevelFromNodeEnv = NODE_ENV === 'test' ? 'fatal' : 'info'; const logLevelFromNodeEnv = NODE_ENV === 'test' ? 'fatal' : 'info';
const errorSerializer = DEV_ENVS.includes(NODE_ENV) ? err : wrapErrorSerializer(err => { const errorSerializer = DEV_ENVS.includes(NODE_ENV) ? err : wrapErrorSerializer(err => {
err.stack = err.stack.split('\n').slice(0, 3).join('\n'); if (err.hasOwnProperty('stack')) {
err.stack = err.stack.split('\n').slice(0, 3).join('\n');
}
return err; return err;
}); });
const options = { const options = {