A catch catches Throwable or Error, which includes failures the program cannot handle

tx0/kotlin:catch-throwablestrictwarningreliability/error-handlingdepth fastsmell

What it finds

catch (t: Throwable) also catches OutOfMemoryError, StackOverflowError and other errors that leave the program in a state it cannot recover from, and on the JVM hides them behind normal handling. Catching the exceptions the code expects says what is handled. Blocks that throw again are left alone, as they only observe the failure.

From the rule's source, catch_throwable.rs.

Example from the rule's tests
fun run() {    try { work() } catch (t: Throwable) { log(t) }tx0 reports: catching Throwable also catches errors    try { work() } catch (e: Error) { log(e) }tx0 reports: catching Error also catches    try { work() } catch (t: Throwable) { log(t); throw t }    try { work() } catch (e: java.io.IOException) { log(e) }}
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 strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:catch-throwable" = "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/kotlin:catch-throwable] reason="..."

tx0 explain tx0/kotlin:catch-throwable shows the same in the terminal. Found a false positive? Report it.