oxc-project/oxc · error · OxcDiagnostic
Prefer omitting the catch binding parameter if it is unused
Error message
Prefer omitting the catch binding parameter if it is unused
What it means
Diagnostic from the unicorn/prefer-optional-catch-binding lint rule. It fires when a `try`/`catch` declares a catch binding parameter (e.g. `catch (error)`) that is never referenced in the catch body; ES2019 allows omitting it entirely (`catch { ... }`). The flagged input is the unused binding pattern's span. It is a lint suggestion, not a runtime error.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/prefer_optional_catch_binding.rs:9
use oxc_ast::{AstKind, ast::BindingPattern};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{AstNode, context::LintContext, rule::Rule};
fn prefer_optional_catch_binding_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Prefer omitting the catch binding parameter if it is unused")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct PreferOptionalCatchBinding;
declare_oxc_lint!(
/// ### What it does
///
/// Prefers omitting the catch binding parameter if it is unused.
///
/// ### Why is this bad?
///
/// It is unnecessary to bind the error to a variable if it is not used.
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:View on GitHub (pinned to e1e7af627c)
Solutions
- Remove the unused catch parameter: write `catch {` instead of `catch (error) {`
- Apply the rule's auto-fix
- If the error is needed later, actually use the binding instead of removing it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/prefer_optional_catch_binding.rs:9 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/2984c3513530a8f8.
Report an issue: GitHub.