< Summary

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

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{
 07  public LgdxNotFound404Exception() : base() { }
 8
 9  public async Task HandleExceptionAsync(HttpContext context)
 010  {
 011    context.Response.ContentType = "application/json";
 012    context.Response.StatusCode = StatusCodes.Status404NotFound;
 013    var problemDetailsFactory = context.RequestServices.GetRequiredService<ProblemDetailsFactory>();
 014    var response = problemDetailsFactory.CreateProblemDetails(
 015      context,
 016      StatusCodes.Status404NotFound,
 017      "Not Found"
 018    );
 019    await context.Response.WriteAsJsonAsync(response);
 020  }
 21}

Methods/Properties

.ctor()
HandleExceptionAsync()