Skip to content

Commit

Permalink
refactor: remove duck typing
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachHaber authored and lamweili committed Sep 29, 2022
1 parent 888e6bc commit 108458e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/LoggingEvent.js
Expand Up @@ -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 },
Expand Down

0 comments on commit 108458e

Please sign in to comment.