An exception object is built and discarded, and nothing raises it

tx0/kotlin:exception-not-throwndefaulterrorreliability/error-handlingdepth fastbug

What it finds

IllegalStateException("closed") on a line of its own creates the exception and drops it: the check it was meant to make does nothing. throw was forgotten.

From the rule's source, exception_not_thrown.rs.

Example from the rule's tests
fun check(open: Boolean): Exception {    if (!open) {        IllegalStateException("closed")tx0 reports: IllegalStateException is created but not thrown    }    val error = IllegalArgumentException("x")    val value = runCatching { work() }.getOrElse { IllegalStateException("wrapped") }    return IllegalStateException("returned")}
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:exception-not-thrown" = "off"

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/kotlin:exception-not-thrown] reason="..."

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