You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following code the inner method InvokeAsync is throwing an OnlineException but I can never catch it what is re-thrown is a simple Exception:
//-- in a singletonCircuitBreakerPolicy=Policy.Handle<Exception>().CircuitBreakerAsync(exceptionsAllowedBeforeBreaking:ExceptionsAllowedForCircuiteBreaker,durationOfBreak:TimeSpan.FromSeconds(BreakTime),onBreak:(ex,breakDelay)=>{Debug.Log($".Breaker logging: Breaking the circuit for {breakDelay.TotalMilliseconds} ms!");Debug.Log($"..due to: + {ex.Message}");},onReset:()=>Debug.Log(".Breaker logging: Call ok! Closed the circuit again!"),onHalfOpen:()=>Debug.Log(".Breaker logging: Half-open: Next call is a trial!"));//--publicvirtualasyncTask<IOnlineResponse>Process(CancellationTokenct){Debug.Log($"Processing = {Type}");State=newRequestState();UserviceResponse=null;AsyncTimeoutPolicytimeoutPolicy=Policy.TimeoutAsync(TimeOut);AsyncRetryPolicywaitAndRetryPolicy=Policy.Handle<Exception>(e =>!(eisBrokenCircuitException)).WaitAndRetryAsync(retryCount:DefaultRetryCount,
attempt =>TimeSpan.FromMilliseconds(AttemptDelay),(exception,calculatedWaitDuration)=>{Debug.Log($".Request exception (will retry): "+exception.Message);});AsyncPolicyWrappolicyWrap=Policy.WrapAsync(timeoutPolicy,waitAndRetryPolicy,CircuitBreaker.Instance.CircuitBreakerPolicy);try{serviceResponse=awaitpolicyWrap.ExecuteAsync(async(cancellationToken)=>{awaitCheckConnectivity(cancellationToken);returnawaitInvokeAsync(cancellationToken);},ct,continueOnCapturedContext:true);State.Status=RequestStatus.Success;State.Message="";}catch(OnlineExceptionex){State.Status=OnlineExceptionStatusToRequestStatus(ex.StatusCode);State.Message=ex.ToString();}catch(Exceptionex){State.Status=RequestStatus.Failed;State.Message=ex.ToString();}Debug.Log($"Response = {Type} - {State.Status}");returnnewV{State=State,Response=serviceResponse};}
The text was updated successfully, but these errors were encountered:
In the following code the inner method InvokeAsync is throwing an OnlineException but I can never catch it what is re-thrown is a simple Exception:
The text was updated successfully, but these errors were encountered: