Skip to content

Commit 7454693

Browse files
authored
fix: e.stack?.split() (#404)
closes #398
1 parent 716f00b commit 7454693

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/logging/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ module.exports = resource => {
122122
attributes['exception.stacktrace'] = e.stack
123123
attributes['exception.type'] = e.name
124124
// remove stack from message, if present
125-
log.msg = log.msg.replace(e.stack, e.stack.split('\n')[0])
125+
// NOTE: an error should always have a stack, but there was an issue report where it somehow was undefined
126+
log.msg = log.msg.replace(e.stack, e.stack?.split('\n')[0])
126127
}
127128
for (const field of custom_fields) if (field in log) attributes[field] = log[field]
128129
logger.emit({

0 commit comments

Comments
 (0)