From 6a47ffa4d3f180c4807ca17594939b765e15751f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Wed, 21 Dec 2022 01:18:49 +0100 Subject: fix(core): Do not print errors prop for non-AggregateError errors (#17123) This commit fixes formatting of JSError with "errors" property. Before this commit all instances of "Error" were treated as if they were "AggregateError" if they had "errors" property. After this commit only actual instances of "AggregateError" are formatted in such a way, while instances of "Error" that have "errors" property are formatted without showing details of "errors". --- cli/tests/run_tests.rs | 7 +++++++ cli/tests/testdata/run/error_with_errors_prop.js | 10 ++++++++++ cli/tests/testdata/run/error_with_errors_prop.js.out | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 cli/tests/testdata/run/error_with_errors_prop.js create mode 100644 cli/tests/testdata/run/error_with_errors_prop.js.out (limited to 'cli/tests') diff --git a/cli/tests/run_tests.rs b/cli/tests/run_tests.rs index 6196f641d..092546aaf 100644 --- a/cli/tests/run_tests.rs +++ b/cli/tests/run_tests.rs @@ -2780,6 +2780,13 @@ mod run { exit_code: 1, }); + // Regression test for https://github.com/denoland/deno/issues/16340. + itest!(error_with_errors_prop { + args: "run --quiet run/error_with_errors_prop.js", + output: "run/error_with_errors_prop.js.out", + exit_code: 1, + }); + // Regression test for https://github.com/denoland/deno/issues/12143. itest!(js_root_with_ts_check { args: "run --quiet --check run/js_root_with_ts_check.js", diff --git a/cli/tests/testdata/run/error_with_errors_prop.js b/cli/tests/testdata/run/error_with_errors_prop.js new file mode 100644 index 000000000..d1c6bbfaa --- /dev/null +++ b/cli/tests/testdata/run/error_with_errors_prop.js @@ -0,0 +1,10 @@ +const error = new Error("Error with errors prop."); +error.errors = [ + new Error("Error message 1."), + new Error("Error message 2."), +]; +console.log(error.stack); +console.log(); +console.log(error); +console.log(); +throw error; diff --git a/cli/tests/testdata/run/error_with_errors_prop.js.out b/cli/tests/testdata/run/error_with_errors_prop.js.out new file mode 100644 index 000000000..3154e86e6 --- /dev/null +++ b/cli/tests/testdata/run/error_with_errors_prop.js.out @@ -0,0 +1,10 @@ +Error: Error with errors prop. + at [WILDCARD]/error_with_errors_prop.js:1:15 + +Error: Error with errors prop. + at [WILDCARD]/error_with_errors_prop.js:1:15 + +error: Uncaught Error: Error with errors prop. +const error = new Error("Error with errors prop."); + ^ + at [WILDCARD]/error_with_errors_prop.js:1:15 -- cgit v1.2.3