voben
01/24/2020, 8:44 AM// Java code
try {
return doDangerousThing();
} catch (ExceptionA | ExceptionB e) {
e.printStackTrace();
}
theyann
01/24/2020, 8:45 AME.Kisaragi
01/24/2020, 8:48 AMthanksforallthefish
01/24/2020, 8:50 AME.Kisaragi
01/24/2020, 8:50 AMErik
01/24/2020, 1:44 PMtry {
return doDangerousThing();
} catch (t: Throwable) {
when (t) {
is IOException, is IllegalStateException -> t.printStackTrace()
else -> throw t
}
}
But the nasty part is that you have to rethrow or you'd swallow the exception.