Related to #5513, we want to create a function/lambda so that we can catch Throwable and safely rethrow errors that we shouldn't catch.
The types of exceptions and errors that should be rethrown should be OOMs, ProcessDeath, Stackoverflow, InterruptedException and other types of errors (research this).
Example
fun rethrowFatal(t: Throwable) {
if (t is X) {
throw t
} else if (t is Y) {
throw t
}
// just ignore or log?
}
so it can be used like:
try {
doDangerousThing()
} catch(t: Throwable) {
rethrowFatal(t)
}
Ideally we shouldn't use this function often, just when we really don't want to crash.
Related to #5513, we want to create a function/lambda so that we can catch
Throwableand safely rethrow errors that we shouldn't catch.The types of exceptions and errors that should be rethrown should be OOMs, ProcessDeath, Stackoverflow, InterruptedException and other types of errors (research this).
Example
so it can be used like:
Ideally we shouldn't use this function often, just when we really don't want to crash.