Skip to content

Commit

Permalink
Revert "Serialize errors with cause (pinojs#105)"
Browse files Browse the repository at this point in the history
This reverts commit ae83956.
  • Loading branch information
voxpelli committed Jun 13, 2022
1 parent cb56e9f commit 23f62f2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
9 changes: 0 additions & 9 deletions lib/err.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ const pinoErrProto = Object.create({}, {
writable: true,
value: undefined
},
cause: {
enumerable: true,
writable: true,
value: undefined
},
raw: {
enumerable: false,
get: function () {
Expand Down Expand Up @@ -65,10 +60,6 @@ function errSerializer (err) {
_err.aggregateErrors = err.errors.map(err => errSerializer(err))
}

if (err.cause) {
_err.cause = errSerializer(err.cause)
}

for (const key in err) {
if (_err[key] === undefined) {
const val = err[key]
Expand Down
24 changes: 0 additions & 24 deletions test/err.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,3 @@ test('serializes aggregate errors', { skip: !global.AggregateError }, function (
t.match(serialized.aggregateErrors[1].stack, /^Error: bar/)
t.match(serialized.stack, /err\.test\.js:/)
})

test('serializes causes', function (t) {
t.plan(11)

const bar = new Error('bar')
bar.cause = new Error('foo')
bar.cause.cause = new Error('baz')

const serialized = serializer(bar)

t.equal(serialized.type, 'Error')
t.equal(serialized.message, 'bar: foo: baz') // message serialization already walks cause-chain
t.match(serialized.stack, /err\.test\.js:/)

t.ok(serialized.cause)
t.equal(serialized.cause.type, 'Error')
t.equal(serialized.cause.message, 'foo: baz')
t.match(serialized.cause.stack, /err\.test\.js:/)

t.ok(serialized.cause.cause)
t.equal(serialized.cause.cause.type, 'Error')
t.equal(serialized.cause.cause.message, 'baz')
t.match(serialized.cause.cause.stack, /err\.test\.js:/)
})

0 comments on commit 23f62f2

Please sign in to comment.