< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.WebApi.Security.SuppressedDeveloperPageFilter
Assembly: ArturRios.Heimdall.WebApi
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Security/SuppressedDeveloperPageFilter.cs
Line coverage
87%
Covered lines: 7
Uncovered lines: 1
Coverable lines: 8
Total lines: 42
Line coverage: 87.5%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 1
Fully covered methods: 0
Total methods: 1
Method coverage: 100%
Full method coverage: 0%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HandleExceptionAsync(...)100%1187.5%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Security/SuppressedDeveloperPageFilter.cs

#LineLine coverage
 1using System.Runtime.ExceptionServices;
 2using ArturRios.Util.WebApi.Middleware;
 3using Microsoft.AspNetCore.Diagnostics;
 4using Microsoft.Extensions.Logging.Abstractions;
 5
 6namespace ArturRios.Heimdall.WebApi.Security;
 7
 8/// <summary>
 9///     NFR-28: answers a failure that reaches a developer exception page the decision has turned off
 10///     with the API's own 500 envelope instead of the page.
 11/// </summary>
 12/// <remarks>
 13///     <para>
 14///         In Development the minimal host adds the developer exception page by itself, inside the
 15///         startup filters and ahead of the standard pipeline, whatever <see cref="SensitiveDiagnostics" />
 16///         says. ExceptionMiddleware sits inside it, so most failures never reach it, but one raised
 17///         ahead of that middleware (in routing, say) would be shown with its stack trace. The page's
 18///         exception filters are the hook the framework offers: this one, registered only where the
 19///         decision keeps the page off, never hands the failure on to the page.
 20///     </para>
 21///     <para>
 22///         The failure is rethrown into a fresh ExceptionMiddleware, so the body is exactly what the
 23///         standard pipeline writes for any other unhandled exception. The page has already logged
 24///         the exception, so that middleware logs nothing more.
 25///     </para>
 26/// </remarks>
 27public sealed class SuppressedDeveloperPageFilter : IDeveloperPageExceptionFilter
 28{
 29    public Task HandleExceptionAsync(ErrorContext errorContext, Func<ErrorContext, Task> next)
 30    {
 131        var failure = ExceptionDispatchInfo.Capture(errorContext.Exception);
 32
 133        var envelope = new ExceptionMiddleware(_ =>
 134        {
 135            failure.Throw();
 136
 037            return Task.CompletedTask;
 138        }, NullLogger<ExceptionMiddleware>.Instance);
 39
 140        return envelope.InvokeAsync(errorContext.HttpContext);
 41    }
 42}