< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.Utilities.APIExceptionHandlers.BusinessExceptionHandler
Assembly: ZhEaIsNsAaBn.Utilities.APIExceptionHandlers
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/UtilitiesPackages/ZhEaIsNsAaBn.Utilities.APIExceptionHandlers/GlobalHandlers/BusinessExceptionHandler.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 34
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
TryHandleAsync()100%22100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/UtilitiesPackages/ZhEaIsNsAaBn.Utilities.APIExceptionHandlers/GlobalHandlers/BusinessExceptionHandler.cs

#LineLine coverage
 1using Microsoft.Extensions.Options;
 2
 3namespace ZhEaIsNsAaBn.Utilities.APIExceptionHandlers;
 4
 5/// <summary>Handles <see cref="UnauthorizedAccessException"/> with an <c>UnAuthorized</c> error (default 401).</summary
 6public sealed class BusinessExceptionHandler : BaseExceptionHandler<BusinessExceptionHandler>, IExceptionHandler
 7{
 8    /// <summary>Creates the handler.</summary>
 9    /// <param name="logger">The logger.</param>
 10    /// <param name="environment">The host environment.</param>
 11    /// <param name="settings">The status mapping.</param>
 12    public BusinessExceptionHandler( ILogger<BusinessExceptionHandler> logger, IWebHostEnvironment environment, IOptions
 19213        : base( logger, environment, settings ) { }
 14
 15
 16    /// <inheritdoc />
 17    public async ValueTask<bool> TryHandleAsync( HttpContext httpContext, Exception exception, CancellationToken cancell
 18    {
 7219        ArgumentNullException.ThrowIfNull( httpContext );
 20
 13621        if ( exception is not UnauthorizedAccessException ) { return false; }
 22
 23
 824        Log.BusinessError( Logger, exception, httpContext.Request.Path, httpContext.Request.Method, httpContext.TraceIde
 25
 26
 827        var error = new Error( "UnAuthorized", "Business", "غير مصرح لك بالوصول إلى هذا المورد", "You are not authorized
 28
 29
 830        await GenerateError( httpContext, error, cancellationToken ).ConfigureAwait( false );
 31
 832        return true;
 7233    }
 34}