Every exception is caught and not thrown again
What it finds
catch (Exception) and a bare catch take every failure, out of memory and bugs included, and the code continues as if they were expected. Catching the exceptions the code can handle keeps the others visible. Handlers that rethrow, or throw a new exception, are left alone.
From the rule's source, general_catch.rs.
using System; class Broad{ void Run() { try { Work(); } catch (Exception e)tx0 reports: every exception is caught here and not thrown again { Console.WriteLine(e); } try { Work(); } catch (Exception e) { throw new InvalidOperationException("work failed", e); } } void Work() { }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:general-catch" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:general-catch] reason="..."tx0 explain tx0/csharp:general-catch shows the same in the terminal. Found a false positive? Report it.