예제 #1
0
        protected static async Task ExecuteWithExceptionHandlingAsync(Func <Task> execute, RequestData requestData)
        {
            try
            {
                await execute().ConfigureAwait(false);
            }
            catch (Exception e)
            {
                if (requestData.ExceptionHandler == null)
                {
                    throw;
                }

                var exceptionArguments = new MethodExceptionHandlerArguments {
                    MethodException = e
                };

                requestData.ExceptionHandler.HandleException(exceptionArguments);

                if (exceptionArguments.Handled)
                {
                    return;
                }

                throw exceptionArguments.MethodException ?? e;
            }
        }
예제 #2
0
        protected static async Task <T> GetValueWithExceptionHandlingAsync <T>(Func <Task <T> > execute, RequestData requestData)
        {
            try
            {
                return(await execute().ConfigureAwait(false));
            }
            catch (Exception e)
            {
                if (requestData.ExceptionHandler == null)
                {
                    throw;
                }

                var exceptionArguments = new MethodExceptionHandlerArguments {
                    MethodException = e
                };

                requestData.ExceptionHandler.HandleException(exceptionArguments);

                if (exceptionArguments.Handled)
                {
                    return((T)requestData.DefaultResult);
                }

                throw exceptionArguments.MethodException ?? e;
            }
        }
        public void HandleException(MethodExceptionHandlerArguments arguments)
        {
            if (!(arguments.MethodException is FaultException faultException))
            {
                return;
            }

            arguments.MethodException = GetCcuException(faultException);
        }