---
title: "unicorn/prefer-optional-catch-binding"
description: "Require `catch {}` without a parameter when the error is not used"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "unicorn"
aliases: []
kind: "suggestion"
category: "style"
default: "off"
fixable: "yes"
typeAware: false
deprecated: false
---

`catch` doesn't need a parameter. A name that's never read sends the reader looking for where the error is handled.

`--fix` removes the parameter and its parentheses.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/prefer-optional-catch-binding" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
function parse(text) {
  try {
    return JSON.parse(text);
  } catch (error) {
    return undefined;
  }
}

try {
  await upload(file);
} catch ({ message }) {
  retry(file);
}
```

Not reported:

{/* good */}
```js
function parse(text) {
  try {
    return JSON.parse(text);
  } catch {
    return undefined;
  }
}

try {
  await upload(file);
} catch ({ message }) {
  console.error(message);
}
```
