Serialisation of AggregateError
paolochiodi opened this issue · 3 comments
paolochiodi commented
I'd like to propose a new feature.
AggregateErrors get serialised as regular errors, displaying only information from the aggregated error.
Including message and stack from the underlying errors, in a similar vain to what has been on #78 could be beneficial and provide a better picture.
Example
const log = require('pino')()
const inner = new Error('inner')
const aggregate = new AggregatedError([inner], 'aggregated')
log.error(aggregate)
Current serialisation
{
"level": 50,
"time": 1640082406574,
"pid": 45285,
"hostname": "hostname1",
"stack": "AggregateError: aggregated\n at REPL18:1:7\n at Script.runInThisContext (node:vm:129:12)\n at REPLServer.defaultEval (node:repl:562:29)\n at bound (node:domain:421:15)\n at REPLServer.runBound [as eval] (node:domain:432:12)\n at REPLServer.onLine (node:repl:889:10)\n at REPLServer.emit (node:events:402:35)\n at REPLServer.emit (node:domain:475:12)\n at REPLServer.Interface._onLine (node:readline:487:10)\n at REPLServer.Interface._line (node:readline:864:8)",
"type": "Error",
"msg": "aggregated"
}
Possible improvement
{
"level": 50,
"time": 1640082406574,
"pid": 45285,
"hostname": "hostname1",
"stack": "AggregateError: aggregated\n at REPL18:1:7\n at Script.runInThisContext (node:vm:129:12)\n at REPLServer.defaultEval (node:repl:562:29)\n at bound (node:domain:421:15)\n at REPLServer.runBound [as eval] (node:domain:432:12)\n at REPLServer.onLine (node:repl:889:10)\n at REPLServer.emit (node:events:402:35)\n at REPLServer.emit (node:domain:475:12)\n at REPLServer.Interface._onLine (node:readline:487:10)\n at REPLServer.Interface._line (node:readline:864:8)",
"type": "Error",
"msg": "aggregated",
"aggregateErrors": [{
"msg": "inner",
"stack": "Error: inner\n at REPL18:1:7\n at Script.runInThisContext (node:vm:129:12)\n at REPLServer.defaultEval (node:repl:562:29)\n at bound (node:domain:421:15)\n at REPLServer.runBound [as eval] (node:domain:432:12)\n at REPLServer.onLine (node:repl:889:10)\n at REPLServer.emit (node:events:402:35)\n at REPLServer.emit (node:domain:475:12)\n at REPLServer.Interface._onLine (node:readline:487:10)\n at REPLServer.Interface._line (node:readline:864:8)"
}]
}
voxpelli commented
I like this, similar in spirit to #76
Speaking of #76, AggregateError
is something I've been meaning to look into with pony-cause
as well: voxpelli/pony-cause#9
mcollina commented
Me too, I think we should support it as well
sameer-coder commented
I am working on this feature. Will create a PR soon