Reports catch clauses that only rethrow the caught error without modification.
✅ This rule is included in the ts logical and logicalStrict presets.
A catch clause that only rethrows the caught error without any modification or additional logic serves no purpose.
It adds unnecessary code complexity and performance overhead without providing any benefit.
Errors will propagate naturally without the catch clause, making it redundant.
AEasy5<3 sp ansty="le--0:#C792EA;--1:#8844">AEfuncti3 sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0fetchDa3 sp>11<()sp ansty="le--0:#D6DEEB;--1:#403F">53()sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEt sp>53 {d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#C792EA;--1:#8844">AEawa3 sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0fet3 sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D/api/da1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp> {d><);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53 sp><} sp ansty="le--0:#C792EA;--1:#8844">AEcat} sp>53 (error));d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEthr sp>53 erro {d>53< sp ansty="le--0:#D6DEEB;--1:#403F">5 sp><3}d ivclassNa="meec-li">53}d><3}d ivclassNa="meec-li">d3}d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0processFi3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53pa1(sp>7<2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0stri3 sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">531)sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEt sp>53 {d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEcons sp>B0conteAE <= sp ansty="le--0:#82AAFF;--1:#3B61">B0readFileSy= sp>53(path {d><);d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0JS3 sp>AB0par53(content);d><);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53 sp><} sp ansty="le--0:#C792EA;--1:#8844">AEcat} sp>53 (exception));d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEthr sp>53 exceptio {d>53< sp ansty="le--0:#D6DEEB;--1:#403F">5 sp><3}d ivclassNa="meec-li">53}d><3}d ivclassNa="meco"><}d>}d>3}d> 44AEa344AEfunc361B0fetch11<11() spans="tyle--0:#D6DEEB;--1:#40">3F11()><53 {divclass="Nameec-">de44A3F53 ><53 {divclass="Nameec-">dent< spans="tyle--0:#C792EA;--1:#88">44AEre >344AEa361B0f31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D/api/111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111">53 ><53) ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53 ><53} spans="tyle--0:#C792EA;--1:#88">44AEc53} >3F53 (erro53)>3F53< spans="tyle--0:#D6DEEB;--1:#40">3F53con >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0e4AE.>31<111" spans="tyle--0:#ECC48D;--1:#98">4E4DFailed to fetch d111">1<111" spans="tyle--0:#889FB2;--1:#4D">6111"><67B, spans="tyle--0:#D6DEEB;--1:#40">3F53 err67B,>dent< spans="tyle--0:#C792EA;--1:#88">44AEt >3F53 er3F<53 spans="tyle--0:#D6DEEB;--1:#40">353 >3c44AEfunc361B0process1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53111(>6361B0st1<111) spans="tyle--0:#D6DEEB;--1:#40">3F111)><53 {divclass="Nameec-">de44A3F53 ><53 {divclass="Nameec-">dent< spans="tyle--0:#C792EA;--1:#88">44AEco >61B0con44A61B0readFile3F53(pa53 >dent< spans="tyle--0:#C792EA;--1:#88">44AEre >361B04<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0p4AE.>3F53(conte | 3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53 ><53} spans="tyle--0:#C792EA;--1:#88">44AEc53} >3F53 (exceptiodent< spans="tyle--0:#C792EA;--1:#88">44AEt >36E7<2new spans="tyle--0:#D6DEEB;--1:#40">32new>61B0E3361B0Failed to process f38<34${ spans="tyle--0:#D6DEEB;--1:#40">3F5334${>3<834} spans="tyle--0:#D6DEEB;--1:#40">3834}>6<67B, spans="tyle--0:#D6DEEB;--1:#40">3F53 { cause: exception67B,>< }) ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">353 > })>3< }> }>
This rule is not configurable.
If you have a specific need to explicitly catch and rethrow errors for documentation purposes or to maintain consistent code structure across multiple try-catch blocks, you might choose to disable this rule.
However, in most cases, removing unnecessary catch clauses improves code clarity and maintainability.