< Summary

Information
Class: LGDXRobotCloud.API.Exceptions.LgdxNotFound404Exception
Assembly: LGDXRobotCloud.API
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Exceptions/LgdxNotFound404Exception.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 21
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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%11100%

File(s)

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

#LineLine coverage
 1using Microsoft.AspNetCore.Mvc.Infrastructure;
 2
 3namespace LGDXRobotCloud.API.Exceptions;
 4
 5public class LgdxNotFound404Exception : Exception, ILgdxExceptionBase
 6{
 1027  public LgdxNotFound404Exception() : base() { }
 8
 9  public async Task HandleExceptionAsync(HttpContext context)
 110  {
 111    context.Response.ContentType = "application/json";
 112    context.Response.StatusCode = StatusCodes.Status404NotFound;
 113    var problemDetailsFactory = context.RequestServices.GetRequiredService<ProblemDetailsFactory>();
 114    var response = problemDetailsFactory.CreateProblemDetails(
 115      context,
 116      StatusCodes.Status404NotFound,
 117      "Not Found"
 118    );
 119    await context.Response.WriteAsJsonAsync(response);
 120  }
 21}

Methods/Properties

.ctor()
HandleExceptionAsync()