diff --git a/CHANGELOG.md b/CHANGELOG.md index ca8c36fe4ad..a99129f2557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.2.5 +* `Coroutines` + * Function `safelyWithoutExceptions` + ## 0.2.4 * `Versions` diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt index c58ba10c3d3..64d3dc86c1d 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt @@ -21,3 +21,10 @@ suspend inline fun safely( onException(e) } } + +/** + * Shortcut for [safely] without exception handler (instead of this you will receive null as a result) + */ +suspend inline fun safelyWithoutExceptions( + noinline block: suspend CoroutineScope.() -> T +): T? = safely({ null }, block)