KT.UNREACHABLE_CATCH_BLOCK
Unreachable 'catch' block
Reports unreachable 'catch' blocks. Catch blocks can be unreachable if the exception has already been caught in the block above.
Noncompliant Code
Copy
fun test() {
try {
foo()
} catch (t: Throwable) {
bar()
} catch (e: Exception) {
// Unreachable
baz()
}
}
Compliant Code
Copy
fun test() {
try {
foo()
} catch (e: Exception) {
baz()
} catch (t: Throwable) {
bar()
}
}