Skip to content

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

Open
MarcusDunn wants to merge 2 commits intofork-handles:trunkfrom
MarcusDunn:resultFromCatching-fix
Open

[result4k] Prevent unintuitively behaving bounds on resultFromCatching from compiling#59
MarcusDunn wants to merge 2 commits intofork-handles:trunkfrom
MarcusDunn:resultFromCatching-fix

Conversation

@MarcusDunn
Copy link
Copy Markdown
Contributor

This prevents the following code from compiling

resultFromCatching<NotImplementedError, _> {
    throw NotImplementedError("catch me if you can")
}

Unintuitively, this would throw instead of resulting in a Failure<NotImplementedError> as resultFrom would not catch it (it only catches Exceptions)

This would be a breaking change but catching Errors is generally a bad idea anyways.

This prevents the following erronious code from compiling

```kotlin
resultFromCatching<NotImplementedError, _>
```

which would not ever result in a `Failure<NotImplementedError> as `resultFrom` would not catch it

```
@MarcusDunn MarcusDunn changed the title Result from catching fix [result4k] Prevent unintuitively behaving bounds on resultFromCatching from compiling Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant