Does Kotlin support catch multiple exceptions simi...
# announcements
t
Does Kotlin support catch multiple exceptions similar to Java now?
🚫 2
Without this support, it can really ends up with some ugly code.
k
yeah, the best we have right now is to catch Exception and then
when
on the exceptions internally:
Copy code
try {
  // ...
} catch (e: Exception) {
  when(e) {
    is IllegalStateException, IllegalArgumentException -> {
      // ...
    }
    else -> throw e
}
but it's still not great
g
This is related feature request
g
not the same, but you may also consider
runCatching{}
.