Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[result4k] Prevent unintuitively behaving bounds on resultFromCatching from compiling #59

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inline fun <T> resultFrom(block: () -> T): Result<T, Exception> =
/**
* Call a block and catch a specific Throwable type, returning it as an `Err` value.
*/
inline fun <reified E : Throwable, T> resultFromCatching(block: () -> T): Result<T, E> = resultFrom(block).mapFailure {
inline fun <reified E : Exception, T> resultFromCatching(block: () -> T): Result<T, E> = resultFrom(block).mapFailure {
when (it) {
is E -> it
else -> throw it
Expand Down
Loading