A too general or runtime-reserved exception type is thrown

tx0/csharp:reserved-exception-thrownrecommendedwarningreliability/error-handlingdepth fastsmell

What it finds

throw new Exception(...) gives callers nothing to catch but everything, and NullReferenceException, IndexOutOfRangeException, OutOfMemoryException and StackOverflowException are meant to be thrown by the runtime: thrown by code, they hide what went wrong. A specific type, such as ArgumentException or InvalidOperationException, or an own exception type, says what happened.

From the rule's source, reserved_exception_thrown.rs.

Example from the rule's tests
using System; class Throws{    void Run(int x)    {        if (x < 0)        {            throw new Exception("negative");tx0 reports: Exception is too general or reserved for the runtime        }        if (x > 9)        {            throw new System.NullReferenceException();tx0 reports: NullReferenceException is too general or reserved for the runtime        }        throw new ArgumentOutOfRangeException(nameof(x));    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:reserved-exception-thrown" = "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:reserved-exception-thrown] reason="..."

tx0 explain tx0/csharp:reserved-exception-thrown shows the same in the terminal. Found a false positive? Report it.