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