From 28348e43aee99b159746d0e28e1814d25d25bffc Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Wed, 24 Nov 2021 17:34:53 +0900 Subject: [PATCH] Have tryTest{} work with throwables Test: NetworkStaticLibTests Change-Id: I9ee52e7d34866c82e169bbecbca3f928bfd79993 --- .../testutils/hostdevice/com/android/testutils/Cleanup.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staticlibs/testutils/hostdevice/com/android/testutils/Cleanup.kt b/staticlibs/testutils/hostdevice/com/android/testutils/Cleanup.kt index 22b9b6c63d..eec8128df0 100644 --- a/staticlibs/testutils/hostdevice/com/android/testutils/Cleanup.kt +++ b/staticlibs/testutils/hostdevice/com/android/testutils/Cleanup.kt @@ -84,7 +84,7 @@ inline class TryExpr(val result: Result) { inline infix fun cleanup(block: () -> Unit): T { try { block() - } catch (e: Exception) { + } catch (e: Throwable) { val originalException = result.exceptionOrNull() if (null == originalException) { throw e @@ -101,7 +101,7 @@ inline class TryExpr(val result: Result) { fun tryTest(block: () -> T) = TryExpr( try { Result.success(block()) - } catch (e: Exception) { + } catch (e: Throwable) { Result.failure(e) })