diff --git a/lib/LoggingEvent.js b/lib/LoggingEvent.js index 780c9eb9..42bc5e06 100644 --- a/lib/LoggingEvent.js +++ b/lib/LoggingEvent.js @@ -39,9 +39,8 @@ class LoggingEvent { serialise() { return flatted.stringify(this, (key, value) => { // JSON.stringify(new Error('test')) returns {}, which is not really useful for us. - // The following allows us to serialize errors correctly. - // duck-typing for Error object - if (value && value.message && value.stack) { + // The following allows us to serialize errors (semi) correctly. + if (value instanceof Error) { // eslint-disable-next-line prefer-object-spread value = Object.assign( { message: value.message, stack: value.stack },