mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
fix: add error cause in recursive cause tail (#16306)
This commit is contained in:
parent
5252ff5dbd
commit
cf1be5e76f
4 changed files with 26 additions and 3 deletions
|
@ -3374,6 +3374,12 @@ itest!(error_cause {
|
|||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(error_cause_recursive_tail {
|
||||
args: "run error_cause_recursive_tail.ts",
|
||||
output: "error_cause_recursive_tail.ts.out",
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(error_cause_recursive {
|
||||
args: "run run/error_cause_recursive.ts",
|
||||
output: "run/error_cause_recursive.ts.out",
|
||||
|
|
5
cli/tests/testdata/error_cause_recursive_tail.ts
vendored
Normal file
5
cli/tests/testdata/error_cause_recursive_tail.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
const foo = new Error("foo");
|
||||
const bar = new Error("bar", { cause: foo });
|
||||
const baz = new Error("baz", { cause: bar });
|
||||
foo.cause = bar;
|
||||
throw baz;
|
12
cli/tests/testdata/error_cause_recursive_tail.ts.out
vendored
Normal file
12
cli/tests/testdata/error_cause_recursive_tail.ts.out
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
[WILDCARD]
|
||||
error: Uncaught Error: baz
|
||||
const baz = new Error("baz", { cause: bar });
|
||||
^
|
||||
at file:///[WILDCARD]/error_cause_recursive_tail.ts:3:13
|
||||
Caused by: Error: bar
|
||||
at file:///[WILDCARD]/error_cause_recursive_tail.ts:2:13
|
||||
Caused by: Error: foo
|
||||
at file:///[WILDCARD]/error_cause_recursive_tail.ts:1:13
|
||||
Caused by: Error: bar
|
||||
at file:///[WILDCARD]/error_cause_recursive_tail.ts:2:13
|
||||
[WILDCARD]
|
|
@ -209,7 +209,7 @@ impl JsError {
|
|||
fn inner_from_v8_exception<'a>(
|
||||
scope: &'a mut v8::HandleScope,
|
||||
exception: v8::Local<'a, v8::Value>,
|
||||
mut seen: HashSet<v8::Local<'a, v8::Value>>,
|
||||
mut seen: HashSet<v8::Local<'a, v8::Object>>,
|
||||
) -> Self {
|
||||
// Create a new HandleScope because we're creating a lot of new local
|
||||
// handles below.
|
||||
|
@ -254,10 +254,10 @@ impl JsError {
|
|||
}
|
||||
});
|
||||
let cause = cause.and_then(|cause| {
|
||||
if cause.is_undefined() || seen.contains(&cause) {
|
||||
if cause.is_undefined() || seen.contains(&exception) {
|
||||
None
|
||||
} else {
|
||||
seen.insert(cause);
|
||||
seen.insert(exception);
|
||||
Some(Box::new(JsError::inner_from_v8_exception(
|
||||
scope, cause, seen,
|
||||
)))
|
||||
|
|
Loading…
Reference in a new issue