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

Information
Class: ZhEaIsNsAaBn.Utilities.APIExceptionHandlers.JsonExceptionHandler
Assembly: ZhEaIsNsAaBn.Utilities.APIExceptionHandlers
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/UtilitiesPackages/ZhEaIsNsAaBn.Utilities.APIExceptionHandlers/GlobalHandlers/JsonExceptionHandler.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 35
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/JsonExceptionHandler.cs

#LineLine coverage
 1using Microsoft.Extensions.Options;
 2
 3namespace ZhEaIsNsAaBn.Utilities.APIExceptionHandlers;
 4
 5/// <summary>Handles <see cref="JsonException"/> (bad request body) with an <c>InvalidJson</c> error, category <c>Valida
 6public sealed class JsonExceptionHandler : BaseExceptionHandler<JsonExceptionHandler>, 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 JsonExceptionHandler( ILogger<JsonExceptionHandler> logger, IWebHostEnvironment environment, IOptions<APIResp
 19213        : base( logger, environment, settings ) { }
 14
 15
 16    /// <inheritdoc />
 17    public async ValueTask<bool> TryHandleAsync( HttpContext httpContext, Exception exception, CancellationToken cancell
 18    {
 9219        ArgumentNullException.ThrowIfNull( httpContext );
 20
 17621        if ( exception is not JsonException jsonException ) { return false; }
 22
 23
 824        Log.JsonError( Logger, jsonException, httpContext.Request.Path, httpContext.Request.Method, httpContext.TraceIde
 25
 26
 827        var error = new Error( "InvalidJson", "Validation", "صيغة JSON غير صالحة أو نوع بيانات غير مطابق في جسم الطلب.",
 828                               "Invalid JSON format or data type mismatch in request body.", Severity.Medium );
 29
 30
 831        await GenerateError( httpContext, error, cancellationToken ).ConfigureAwait( false );
 32
 833        return true;
 9234    }
 35}