throw If Unchecked
Throws this if it is not null and a RuntimeException or Error. Example usage:
var failure: Throwable? = null
for (foo: Foo in foos) {
try {
foo.bar()
} catch (t: RuntimeException) {
failure = t
} catch (t: Error) {
failure = t
}
}
failure.throwIfInstanceOf<BarException>()
failure.throwIfUnchecked
throw AssertionError(failure)Content copied to clipboard