< Summary

Information
Class: LGDXRobotCloud.API.Exceptions.LgdxIdentity400Expection
Assembly: LGDXRobotCloud.API
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Exceptions/LgdxValidationList400Expection.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 25
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%
HandleExceptionAsync()100%22100%

File(s)

/builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Exceptions/LgdxValidationList400Expection.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Identity;
 2using Microsoft.AspNetCore.Mvc.Infrastructure;
 3using Microsoft.AspNetCore.Mvc.ModelBinding;
 4
 5namespace LGDXRobotCloud.API.Exceptions;
 6
 207public class LgdxIdentity400Expection(IEnumerable<IdentityError> errors) : Exception(), ILgdxExceptionBase
 8{
 9  public async Task HandleExceptionAsync(HttpContext context)
 110  {
 111    context.Response.ContentType = "application/json";
 112    context.Response.StatusCode = StatusCodes.Status400BadRequest;
 113    ModelStateDictionary modelState = new();
 514    foreach (var error in errors)
 115    {
 116      modelState.AddModelError(error.Code, error.Description);
 117    }
 118    var problemDetailsFactory = context.RequestServices.GetRequiredService<ProblemDetailsFactory>();
 119    var response = problemDetailsFactory.CreateValidationProblemDetails(
 120      context,
 121      modelState
 122    );
 123    await context.Response.WriteAsJsonAsync(response);
 124  }
 25}