After final failure wrap and throw a new exception
Hi,
I'm doing something like this:
return await Policy
.Handle
This is a generic handler where I inject the strategy and the code to be run. However in some cases I need the handler to catch a final (e.g.) "Service Slow" exception and then raise a Service Unavailable instead. As this is a generic handler, it's only applicable in a few cases so I don't really want to write a custom handler with a try - catch for this.
Can this be done in Polly? (maybe use the retry count?)
I think we should come at this from a different direction,
we should add to the policy builder a new method called AfterFinalRetry(Action
I will try to do it this weekend...
sounds good to me, thanks
Hey, made this fork https://github.com/yftachman/Polly
should contain the changes you need. if there are any problems with it let me know. i'm not that familiar with this project so problems may arise
Example syntax:
Policy.Handle
gl hf :)
I'd like a little more consistency with the .NET framework.
Instead of having a AfterFinalRetryFailure, perhaps something more generic where you tell it when you want a delegate to run.
We have this in TPL. Task.Factory.StartNew(() => {}) .ContinueWith(task => { /* Do stuff*/ }, TaskContinuationOptions.OnlyOnFaulted)
I guess this means it would come back to a solution which uses a Policy
This would be super useful...
@michael-wolfenden is this something you would consider merging in to the main branch?
I have just released the latest version (2.2.3) with includes post execution support. This should allow you do what you are suggesting.
Thanks for this