Represents an exception and the contextual data associated with it when exception was caught.
コード例 #1
0
ファイル: MethodInterceptor.cs プロジェクト: werdes/Flatwhite
        private async Task HandleExceptionAsync(MethodExceptionContext exceptionContext)
        {
            var attributes = GetInvocationMethodFilterAttributes(exceptionContext.Invocation, exceptionContext.InvocationContext);
            var exceptionFilterAttributes = attributes.OfType <ExceptionFilterAttribute>().ToList();

            if (exceptionFilterAttributes.Count == 0)
            {
                throw exceptionContext.Exception;
            }

            foreach (var f in exceptionFilterAttributes)
            {
                try
                {
                    if (!exceptionContext.Handled)
                    {
                        await f.OnExceptionAsync(exceptionContext).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    throw new AggregateException(ex.Message, ex, exceptionContext.Exception);
                }
            }

            if (!exceptionContext.Handled)
            {
                throw exceptionContext.Exception;
            }
        }
コード例 #2
0
        public virtual Task OnExceptionAsync(MethodExceptionContext exceptionContext)
        {
            try
            {
                OnException(exceptionContext);
            }
            catch (Exception ex)
            {
                TaskHelpers.FromError(ex);
            }

            return TaskHelpers.DefaultCompleted;
        }
コード例 #3
0
        public virtual Task OnExceptionAsync(MethodExceptionContext exceptionContext)
        {
            try
            {
                OnException(exceptionContext);
            }
            catch (Exception ex)
            {
                return(TaskHelpers.FromError(ex));
            }

            return(TaskHelpers.DefaultCompleted);
        }
コード例 #4
0
 public virtual void OnException(MethodExceptionContext exceptionContext)
 {
 }
コード例 #5
0
 public virtual void OnException(MethodExceptionContext exceptionContext)
 {
 }