HandleAllMethodExceptions

目录

1 HandleAllMethodExceptions 

1.1 OnMethodExecutedAsync

1.2 OnMethodExecuting

1.3 OnMethodExecutingAsync

  1. HandleAllMethodExceptions 

using System;

using System.Threading.Tasks;

namespace Flatwhite.Core.Tests.Attributes

{

public class HandleAllMethodExceptions : ExceptionFilterAttribute

{

    1. OnException

public override void OnException(MethodExceptionContext exceptionContext)

{

exceptionContext.Handled = true;

exceptionContext.InvocationContext[$"{nameof(HandleAllMethodExceptions)}.{nameof(OnException)}"] = DateTime.UtcNow;

}

    1. OnExceptionAsync

public override Task OnExceptionAsync(MethodExceptionContext exceptionContext)

{

exceptionContext.Handled = true;

exceptionContext.InvocationContext[$"{nameof(HandleAllMethodExceptions)}.{nameof(OnExceptionAsync)}"] = DateTime.UtcNow;

return Task.CompletedTask;

}

}

}

using System;
using System.Threading.Tasks;

namespace Flatwhite.Core.Tests.Attributes
{
    public class HandleAllMethodExceptions : ExceptionFilterAttribute
    {
        public override void OnException(MethodExceptionContext exceptionContext)
        {
            exceptionContext.Handled = true;
            exceptionContext.InvocationContext[$"{nameof(HandleAllMethodExceptions)}.{nameof(OnException)}"] = DateTime.UtcNow;
        }

        public override Task OnExceptionAsync(MethodExceptionContext exceptionContext)
        {
            exceptionContext.Handled = true;
            exceptionContext.InvocationContext[$"{nameof(HandleAllMethodExceptions)}.{nameof(OnExceptionAsync)}"] = DateTime.UtcNow;
            return Task.CompletedTask;
        }
    }
}

你可能感兴趣的:(Flatwhite,java,开发语言)