From 46df06210101864a6e9ce64279f6bb635d260262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20Pr=C3=BCnster?= Date: Mon, 10 Jun 2024 17:50:08 +0200 Subject: [PATCH] fix `catching` issues --- src/commonMain/kotlin/at/asitplus/KmmResult.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/commonMain/kotlin/at/asitplus/KmmResult.kt b/src/commonMain/kotlin/at/asitplus/KmmResult.kt index 71861bd..d050a3f 100644 --- a/src/commonMain/kotlin/at/asitplus/KmmResult.kt +++ b/src/commonMain/kotlin/at/asitplus/KmmResult.kt @@ -206,7 +206,8 @@ private constructor( * Re-throws any fatal exceptions, such as `OutOfMemoryError`. Relies on [Arrow](https://arrow-kt.io)'s * [nonFatalOrThrow](https://apidocs.arrow-kt.io/arrow-core/arrow.core/non-fatal-or-throw.html) internally. */ -inline fun catching(block: () -> T): KmmResult { +@Suppress("TooGenericExceptionCaught") +inline fun catching(block: () -> T): KmmResult { return try { KmmResult.success(block()) } catch (e: Throwable) { @@ -220,10 +221,11 @@ inline fun catching(block: () -> T): KmmResult { * Re-throws any fatal exceptions, such as `OutOfMemoryError`. Relies on [Arrow](https://arrow-kt.io)'s * [nonFatalOrThrow](https://apidocs.arrow-kt.io/arrow-core/arrow.core/non-fatal-or-throw.html) internally. */ -inline fun T.catching(block: T.() -> R): KmmResult { +@Suppress("TooGenericExceptionCaught") +inline fun T.catching(block: T.() -> R): KmmResult { return try { KmmResult.success(block()) } catch (e: Throwable) { KmmResult.failure(e) } -} \ No newline at end of file +}