Skip to content

[Feature Request] support AggregateError #1675

Open
@safareli

Description

@safareli

Is your feature request related to a problem? Please describe.

In node.js as well as in web browsers one can declare errors like:

new AggregateError(
  [
    new Error("test error 1"),
    new Error("test error 2", { cause: new Error("test error 3") }),
    new Error("test error 4"),
  ],
  "test error"
);

this is what that error looks like if you console.log it in node

Welcome to Node.js v20.11.1.
Type ".help" for more information.
> console.log(new AggregateError([ new Error("test error 1"), new Error("test error 2", { cause: new Error("test error 3") }), new Error("test error 4") ], "test error"))
AggregateError: test error
    at REPL1:1:5
    at ContextifyScript.runInThisContext (node:vm:121:12)
    at REPLServer.defaultEval (node:repl:599:22)
    at bound (node:domain:432:15)
    at REPLServer.runBound [as eval] (node:domain:443:12)
    at REPLServer.onLine (node:repl:929:10)
    at REPLServer.emit (node:events:530:35)
    at REPLServer.emit (node:domain:488:12)
    at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
    at [_line] [as _line] (node:internal/readline/interface:887:18) {
  [errors]: [
    Error: test error 1
        at REPL1:1:31
        at ContextifyScript.runInThisContext (node:vm:121:12)
        at REPLServer.defaultEval (node:repl:599:22)
        at bound (node:domain:432:15)
        at REPLServer.runBound [as eval] (node:domain:443:12)
        at REPLServer.onLine (node:repl:929:10)
        at REPLServer.emit (node:events:530:35)
        at REPLServer.emit (node:domain:488:12)
        at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
        at [_line] [as _line] (node:internal/readline/interface:887:18),
    Error: test error 2
        at REPL1:1:61
        at ContextifyScript.runInThisContext (node:vm:121:12)
        ... 7 lines matching cause stack trace ...
        at [_line] [as _line] (node:internal/readline/interface:887:18) {
      [cause]: Error: test error 3
          at REPL1:1:96
          at ContextifyScript.runInThisContext (node:vm:121:12)
          at REPLServer.defaultEval (node:repl:599:22)
          at bound (node:domain:432:15)
          at REPLServer.runBound [as eval] (node:domain:443:12)
          at REPLServer.onLine (node:repl:929:10)
          at REPLServer.emit (node:events:530:35)
          at REPLServer.emit (node:domain:488:12)
          at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
          at [_line] [as _line] (node:internal/readline/interface:887:18)
    },
    Error: test error 4
        at REPL1:1:129
        at ContextifyScript.runInThisContext (node:vm:121:12)
        at REPLServer.defaultEval (node:repl:599:22)
        at bound (node:domain:432:15)
        at REPLServer.runBound [as eval] (node:domain:443:12)
        at REPLServer.onLine (node:repl:929:10)
        at REPLServer.emit (node:events:530:35)
        at REPLServer.emit (node:domain:488:12)
        at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
        at [_line] [as _line] (node:internal/readline/interface:887:18)
  ]
}

Describe the solution you'd like

Would be amazing if temporal extracted and stored child errors of the AggregateError, right now it supports only single child in cause.

or at least include stack traces of children in the stack trace of the top error using something like require("util").inspect(exception, { showHidden: false, depth: null, colors: false }) (note the stack tracing fixing function that cuts off internal calls from trace should be adopted to not cut things off in this format)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions