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
Exceptions within TryAsync<T>.IfFail handler re-call the same handler #1079
Comments
Of course, the issue is that the language-ext/LanguageExt.Core/Monads/Alternative Value Monads/Try/TryAsync/TryAsync.Extensions.cs Lines 293 to 305 in d5248b6
|
I'm midway through a massive refactor at the moment, so I won't get to this any time soon. My suggestion would be that if you have a decent workaround, wrap it up in an extension method and use that; then it can all be changed later (as well as being a bit more convenient than writing out the same match expression many times). |
By the way, if you want better error handling in general, check out You don't need to use the runtime version ( |
We've got several places where we would like to handle some errors, but if we can't handle the error, re-throw. This allows our the stock GRPC framework to catch that exception and send the client the correct error code, for example.
We'd like to use
IfFail
to do this processing, as shown below. However, whenever we rethrow, it gets handled twice. For example, the following code ends in two lines saying "We've never seen this error before!"This is not the behavior that happens when we use
Match
:We've resorted to using
Match
for the time being, but it would be more pleasant to be able to useIfFail
for this, and it doesn't seem like intentional behavior. If the handler failed to handle the original error, how would we expect it to handle its own error?The text was updated successfully, but these errors were encountered: