Fix handling of Throwable in tryTest/catch
Throwable could be used as a type argument to catch(), but it would possibly never be caught, because the method only catches Exception. Notably, junit assertions fail with AssertionError, which is not a subclass of Exception. Due to that, tests or utilities like DeviceConfigRule that have failing assertions in catch() would not run the subsequent cleanup steps. Bug: 210377950 Test: atest CleanupTest Change-Id: I54e2922cb466f077ba4d219f8c3c6f885316296c
This commit is contained in:
@@ -90,7 +90,7 @@ inline class TryExpr<T>(val result: Result<T>) {
|
||||
if (originalException !is E) return this
|
||||
return TryExpr(try {
|
||||
Result.success(block(originalException))
|
||||
} catch (e: Exception) {
|
||||
} catch (e: Throwable) {
|
||||
Result.failure(e)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user