-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Logging the final exception? #383
Comments
triage of recent issues: Another interim suggestion for logging the final exception/failure would be to use I have not yet provided the promised |
Thanks @reisenberger , I took a look at custom policies but I'm not confident enough about Polly's internals to create a Policy without guidance. |
Closing, as we have proposed a number of possible solutions here. To recap: the original issue was that we closed down the possibility of using a non-generic A further option
|
Hello @reisenberger , wouldn't .Fallback with an Action prevent the Exception from actually bubbling? Is it safe to rethrow the exception from onFallback, after logging of course? Thank you. |
Throwing an exception from within either
|
Hello,
In order to log the final exception after all retries have failed we are currently using the fallback event:
var fallbackPolicy = builder.FallbackAsync((token, context) => { return Task.CompletedTask; }, (ex, context) => LogFinalError(ex, context));
As suggested in another thread. However since the last update this operation now longer works, we are getting an exception:
You have executed the generic .Execute<TResult> method on a non-generic FallbackPolicy. A non-generic FallbackPolicy only defines a fallback action which returns void; it can never return a substitute TResult value. To use FallbackPolicy to provide fallback TResult values you must define a generic fallback policy FallbackPolicy<TResult>. For example, define the policy as Policy<TResult>.Handle<Whatever>.Fallback<TResult>(/* some TResult value or Func<..., TResult> */);
I suppose this is linked to the fix #294 ?
Is there a way to attach an event on fallback without having to handle the return type?
By the way this library is great, keep on the good work!
The text was updated successfully, but these errors were encountered: