From 22a096dab3efb4d2b9c7f841884e72952e6c2eb3 Mon Sep 17 00:00:00 2001 From: marcus Date: Sun, 31 Mar 2024 12:47:55 -0700 Subject: [PATCH 1/2] fixed bounds on `E` in `resultFromCatching` to match `resultFrom` This prevents the following erronious code from compiling ```kotlin resultFromCatching ``` which would not ever result in a `Failure as `resultFrom` would not catch it ``` --- .../core/src/main/kotlin/dev/forkhandles/result4k/result.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/result4k/core/src/main/kotlin/dev/forkhandles/result4k/result.kt b/result4k/core/src/main/kotlin/dev/forkhandles/result4k/result.kt index a357ef5..068e148 100644 --- a/result4k/core/src/main/kotlin/dev/forkhandles/result4k/result.kt +++ b/result4k/core/src/main/kotlin/dev/forkhandles/result4k/result.kt @@ -23,7 +23,7 @@ inline fun resultFrom(block: () -> T): Result = /** * Call a block and catch a specific Throwable type, returning it as an `Err` value. */ -inline fun resultFromCatching(block: () -> T): Result = resultFrom(block).mapFailure { +inline fun resultFromCatching(block: () -> T): Result = resultFrom(block).mapFailure { when (it) { is E -> it else -> throw it From 5d61869ec10b68beb91f973eef80fb3919c0c667 Mon Sep 17 00:00:00 2001 From: marcus Date: Sun, 31 Mar 2024 12:53:12 -0700 Subject: [PATCH 2/2] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e09f1..e5715fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ This list is not intended to be all-encompassing - it will document major and breaking API changes with their rationale when appropriate: +### v2.16.0.0 +- **result4k** : [Breaking change] Changed bounds in `resultFromCatching` from `Throwable` to `Exception`. + ### v2.15.1.0 - **data4k** : Rename methods for consistency. Old methods have been deprecated.