functional/no-try-statements

February 22, 2026 Β· View on GitHub

πŸ“ Disallow try-catch[-finally] and try-finally patterns.

πŸ’ΌπŸš« This rule is enabled in the following configs: badge-noExceptions noExceptions, πŸ”’ strict. This rule is disabled in the following configs: β˜‘οΈ lite, βœ… recommended.

This rule disallows the try keyword.

Rule Details

Try statements are not part of functional programming. See no-throw-statements for more information.

❌ Incorrect

/* eslint functional/no-try-statements: "error" */

try {
  doSomethingThatMightGoWrong(); // <-- Might throw an exception.
} catch (error) {
  // Handle error.
}

βœ… Correct

/* eslint functional/no-try-statements: "error" */

doSomethingThatMightGoWrong() // <-- Returns a Promise
  .catch((error) => {
    // Handle error.
  });

Options

This rule accepts an options object of the following type:

type Options = {
  allowCatch: boolean;
  allowFinally: boolean;
};

Default Options

const defaults = {
  allowCatch: false,
  allowFinally: false,
};

allowCatch

If true, try-catch statements are allowed.

allowFinally

If true, try-finally statements are allowed.