> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# prefer-catch

[Added in v0.6.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.4)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, promisePlugin } from '@rslint/core';

export default defineConfig([
  promisePlugin.configs.recommended,
  {
    rules: {
      'promise/prefer-catch': 'error',
    },
  },
]);
```

Prefer `.catch()` over `.then(null, fn)` or `.then(a, b)` for error handling.

## Rule Details

A `.then()` call with two arguments can obscure that an error handler is present.
The second argument also only catches rejections from earlier in the chain — not
from the first argument — so `.catch()` is both clearer and semantically preferred.

Examples of **incorrect** code for this rule:

```javascript
hey.then(fn1, fn2)
hey.then(null, fn2)
hey.then(undefined, fn2)
```

Examples of **correct** code for this rule:

```javascript
prom.then(fn)
prom.catch(handleErr).then(handle)
prom.catch(handleErr)
```

## Differences from ESLint

Fixed an upstream autofix bug: `x.then(a, b, c)` now fixes to `x.catch(b).then(a, c)` instead of `x.catch(b).then(ac)`.

## Original Documentation

- [eslint-plugin-promise: prefer-catch](https://github.com/eslint-community/eslint-plugin-promise/blob/v7.3.0/docs/rules/prefer-catch.md)
- [Source code](https://github.com/eslint-community/eslint-plugin-promise/blob/v7.3.0/rules/prefer-catch.js)
