< Summary

Information
Class: LGDXRobotCloud.API.Middleware.LgdxExpectionHandlingMiddleware
Assembly: LGDXRobotCloud.API
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Middleware/LgdxExpectionHandlingMiddleware.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 36
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
InvokeAsync()0%620%
HandleExceptionAsync()100%210%

File(s)

/builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.API/Middleware/LgdxExpectionHandlingMiddleware.cs

#LineLine coverage
 1using LGDXRobotCloud.API.Exceptions;
 2namespace LGDXRobotCloud.API.Middleware;
 3
 04public class LgdxExpectionHandlingMiddleware(RequestDelegate next)
 5{
 06  private readonly RequestDelegate _next = next;
 7
 8  public async Task InvokeAsync(HttpContext context)
 09  {
 10    try
 011    {
 012      await _next(context);
 013    }
 014    catch (Exception ex)
 015    {
 016      if (ex is ILgdxExceptionBase casted)
 017      {
 018        await HandleExceptionAsync(context, casted);
 019      }
 020      else throw;
 21    }
 022  }
 23
 24  private static async Task HandleExceptionAsync(HttpContext context, ILgdxExceptionBase ex)
 025  {
 026    await ex.HandleExceptionAsync(context);
 027  }
 28}
 29
 30public static class LgdxExpectionHandlingMiddlewareExtensions
 31{
 32  public static IApplicationBuilder UseLgdxExpectionHandling(this IApplicationBuilder builder)
 33  {
 34    return builder.UseMiddleware<LgdxExpectionHandlingMiddleware>();
 35  }
 36}