| File: Filters\ExceptionFilterAttribute.cs | Web Access |
| Project: src\aspnetcore\src\Mvc\Mvc.Core\src\Microsoft.AspNetCore.Mvc.Core.csproj (Microsoft.AspNetCore.Mvc.Core) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.AspNetCore.Mvc.Filters; /// <summary> /// An abstract filter that runs asynchronously after an action has thrown an <see cref="Exception"/>. Subclasses /// must override <see cref="OnException"/> or <see cref="OnExceptionAsync"/> but not both. /// </summary> [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public abstract class ExceptionFilterAttribute : Attribute, IAsyncExceptionFilter, IExceptionFilter, IOrderedFilter { /// <inheritdoc /> public int Order { get; set; } /// <inheritdoc /> public virtual Task OnExceptionAsync(ExceptionContext context) { ArgumentNullException.ThrowIfNull(context); OnException(context); return Task.CompletedTask; } /// <inheritdoc /> public virtual void OnException(ExceptionContext context) { } }