Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/oxc_linter/src/rules/eslint/preserve_caught_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ impl<'a> Visit<'a> for ThrowFinder<'a, '_> {

// Do not traverse into nested functions/closures within the catch block
fn visit_function(&mut self, _func: &Function<'a>, _flags: ScopeFlags) {}

// Do not traverse into nested catch clauses. They have their own caught error and will be
// analyzed separately when visiting their associated `TryStatement`.
fn visit_catch_clause(&mut self, _catch_clause: &CatchClause<'a>) {}
}

fn is_builtin_error_constructor(expr: &Expression, ctx: &LintContext) -> bool {
Expand Down Expand Up @@ -407,6 +411,10 @@ fn test() {
}"#,
Some(serde_json::json!([{ "requireCatchParameter": false }])),
),
(
r#"try { doSomething(); } catch (errorA) { try { doSomethingElse(); } catch (errorB) { throw new Error( `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${errorA.message}`, { cause: errorB }); } }"#,
None,
),
];

let fail = vec![
Expand Down
Loading