Have tryTest{} work with throwables
Test: NetworkStaticLibTests Change-Id: I9ee52e7d34866c82e169bbecbca3f928bfd79993
This commit is contained in:
@@ -84,7 +84,7 @@ inline class TryExpr<T>(val result: Result<T>) {
|
|||||||
inline infix fun cleanup(block: () -> Unit): T {
|
inline infix fun cleanup(block: () -> Unit): T {
|
||||||
try {
|
try {
|
||||||
block()
|
block()
|
||||||
} catch (e: Exception) {
|
} catch (e: Throwable) {
|
||||||
val originalException = result.exceptionOrNull()
|
val originalException = result.exceptionOrNull()
|
||||||
if (null == originalException) {
|
if (null == originalException) {
|
||||||
throw e
|
throw e
|
||||||
@@ -101,7 +101,7 @@ inline class TryExpr<T>(val result: Result<T>) {
|
|||||||
fun <T> tryTest(block: () -> T) = TryExpr(
|
fun <T> tryTest(block: () -> T) = TryExpr(
|
||||||
try {
|
try {
|
||||||
Result.success(block())
|
Result.success(block())
|
||||||
} catch (e: Exception) {
|
} catch (e: Throwable) {
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user