feat: Better formatting for AggregateError (#14285)

This commit adds "aggregated" field to "deno_core::JsError" that stores
instances of "JsError" recursively to properly handle "AggregateError"
formatting. Appropriate logics was added to "PrettyJsError" and
"console" API to format AggregateErrors.

Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
This commit is contained in:
Bartek Iwańczuk 2022-04-16 16:12:26 +02:00 committed by GitHub
parent 0bb96cde72
commit a87be28a46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 210 additions and 78 deletions

18
cli/tests/testdata/complex_error.ts vendored Normal file
View file

@ -0,0 +1,18 @@
const error = new AggregateError(
[
new AggregateError([new Error("qux1"), new Error("quux1")]),
new Error("bar1", { cause: new Error("baz1") }),
],
"foo1",
{
cause: new AggregateError([
new AggregateError([new Error("qux2"), new Error("quux2")]),
new Error("bar2", { cause: new Error("baz2") }),
], "foo2"),
},
);
console.log(error.stack);
console.log();
console.log(error);
console.log();
throw error;