| | | 1 | | using Microsoft.Extensions.Options; |
| | | 2 | | |
| | | 3 | | namespace ZhEaIsNsAaBn.Utilities.APIExceptionHandlers; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Handles every exception the other handlers didn't, with <see cref="Error.Unknown"/> (default 500). <c>Build()</c> al |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class FallbackExceptionHandler : BaseExceptionHandler<FallbackExceptionHandler>, IExceptionHandler |
| | | 9 | | { |
| | | 10 | | /// <summary>Creates the handler.</summary> |
| | | 11 | | /// <param name="logger">The logger.</param> |
| | | 12 | | /// <param name="environment">The host environment.</param> |
| | | 13 | | /// <param name="settings">The status mapping.</param> |
| | | 14 | | public FallbackExceptionHandler( ILogger<FallbackExceptionHandler> logger, IWebHostEnvironment environment, IOptions |
| | 192 | 15 | | : base( logger, environment, settings ) { } |
| | | 16 | | |
| | | 17 | | |
| | | 18 | | /// <inheritdoc /> |
| | | 19 | | public async ValueTask<bool> TryHandleAsync( HttpContext httpContext, Exception exception, CancellationToken cancell |
| | | 20 | | { |
| | 21 | 21 | | ArgumentNullException.ThrowIfNull( httpContext ); |
| | 21 | 22 | | ArgumentNullException.ThrowIfNull( exception ); |
| | | 23 | | |
| | 21 | 24 | | Log.Unhandled( Logger, exception, httpContext.Request.Path, httpContext.Request.Method, httpContext.TraceIdentif |
| | | 25 | | |
| | | 26 | | |
| | 21 | 27 | | await GenerateError( httpContext, Error.Unknown( exception ), cancellationToken ).ConfigureAwait( false ); |
| | | 28 | | |
| | 21 | 29 | | return true; |
| | 21 | 30 | | } |
| | | 31 | | } |