private void InvokeOnException(Exception exception, bool?okToContinue) { //MessageBox.Show(exception.Message); OnExceptionHandler exceptionHandler = OnException; if (exceptionHandler != null) { //Debug.WriteLine(string.Format("[SocketClient]11C CallingExceptionHandler")); exceptionHandler.BeginInvoke(this, exception, okToContinue, EndInvokeException, null); } //if (exception.Message == "Unable to open the database file") okToContinue = true; //Debug.WriteLine(string.Format("[SocketClient]11D ok to continue")); if (okToContinue == false) { //Debug.WriteLine(string.Format("[SocketClient]11E Dispose()")); Dispose(); } //Debug.WriteLine(string.Format("[SocketClient]11F Out Invoke")); }
public async Task WrapAsync_should_call_on_exception_handler() { int maxRetries = 1; var filters = new ExceptionFilters(new[] { new ExceptionFilter(ex => ex is ApplicationException) }); var hit = false; OnExceptionHandler onException = ctx => { hit = true; return(Task.CompletedTask); }; var sut = new RetryPolicy(maxRetries, filters, null, onException); Func <Task <bool> > action = () => throw new ApplicationException(); await Assert.ThrowsAsync <ApplicationException>(async() => await sut.WrapAsync(action)); hit.Should().BeTrue(); }
public async Task WrapAsync_should_run_OnException_handler() { var filters = new ExceptionFilters(Enumerable.Empty <ExceptionFilter>()); DelayFactory delayFactory = i => TimeSpan.Zero; var hit = false; OnExceptionHandler onException = ctx => { hit = true; return(Task.CompletedTask); }; var sut = new RetryPolicy(1, filters, delayFactory, onException); await Assert.ThrowsAsync <ApplicationException>(async() => await sut.WrapAsync(() => { throw new ApplicationException(); })); hit.Should().BeTrue(); }
//================================================================================ // 関数 //================================================================================ /// <summary> /// Addressable 内部から Exception が渡された時に呼び出されます /// </summary> private void CatchException(AsyncOperationHandle handle, Exception exception) { m_exceptionHandler?.Invoke(exception); OnExceptionHandler?.Invoke(handle, exception); }