1 # Disallow unnecessary catch clauses (no-useless-catch)
3 A `catch` clause that only rethrows the original error is redundant, and has no effect on the runtime behavior of the program. These redundant clauses can be a source of confusion and code bloat, so it's better to disallow these unnecessary `catch` clauses.
7 This rule reports `catch` clauses that only `throw` the caught error.
9 Examples of **incorrect** code for this rule:
12 /*eslint no-useless-catch: "error"*/
15 doSomethingThatMightThrow();
21 doSomethingThatMightThrow();
29 Examples of **correct** code for this rule:
32 /*eslint no-useless-catch: "error"*/
35 doSomethingThatMightThrow();
37 doSomethingBeforeRethrow();
42 doSomethingThatMightThrow();
48 doSomethingThatMightThrow();
56 If you don't want to be notified about unnecessary catch clauses, you can safely disable this rule.