how to try an alternative for failed Try with a new call that returns a Try
See original GitHub issueSo what i’m looking for is something like what other frameworks (jvm) calls
public Try<T> OrElseTry(this Try<T>, Func<T> alternative)
So if the this Try
is in Error then alternative is called
Is that possible? It seems resonable.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Should try-catch blocks be used when calling functions that ...
There's an alternative to exceptions using a return value that may represent an error but I'm going to ignore that option in this...
Read more >try / else with return in try block - python
When you call divide(1, 1) , the try clause runs successfully, and returns. So the else clause is never reached. Why does the...
Read more >How to handle errors with grace: failing silently is not an ...
Catch early, catch often. Catch your exceptions as close to the source at the lowest level possible. Maintain consistency and hide the details...
Read more >The try-with-resources Statement - Exceptions
This Java tutorial describes exceptions, basic input/output, concurrency, regular expressions, and the platform environment.
Read more >Error Handling in Go that Every Beginner should Know
There are two common methods for handling errors in Go — Multiple return values and panic. Error Handling using Multiple Return Values. We...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for quick reply. I can live with that extension. I feared that I missed something, I’m not used to frameworks so Haskell’ish near.
@mathiasbn Hi Mathias, a bit late, but this is fixed in
v2.2.7-beta
There is now a
choice
function in thePrelude
forTry
,TryOption
,TryAsync
,TryOptionAsync
, andTask
.For example:
Plus
is available for chaining OR operations.Obviously that’s not quite as elegant as the
choice
approach.