A catch block tests the type of the caught exception, which separate catch clauses express directly
What it finds
catch (e: Exception) { if (e is IOException) ... } sorts exceptions by hand. A catch clause per type says the same, and does not catch the types nobody handles.
From the rule's source, type_check_in_catch.rs.
fun fetch() { try { load() } catch (e: Exception) { if (e is java.io.IOException) retry()tx0 reports: the type of e is tested inside catch log(e) } try { load() } catch (e: java.io.IOException) { retry() }} 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/kotlin:type-check-in-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/kotlin:type-check-in-catch] reason="..."tx0 explain tx0/kotlin:type-check-in-catch shows the same in the terminal. Found a false positive? Report it.