# Summary

Class: | WireMock.Owin.GlobalExceptionMiddleware
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Owin\GlobalExceptionMiddleware.cs
Covered lines: | 12
Uncovered lines: | 5
Coverable lines: | 17
Total lines: | 56
Line coverage: | 70.5%
Branch coverage: | 58.3%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
.ctor(...) | 0 | 0 | 1 | 0
Invoke() | 0 | 0 | 0.5 | 0.583

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Owin\GlobalExceptionMiddleware.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Threading.Tasks;`
|  | `3` |  | `using Newtonsoft.Json;`
|  | `4` |  | `#if !USE_ASPNETCORE`
|  | `5` |  | `using Microsoft.Owin;`
|  | `6` |  | `#else`
|  | `7` |  | `using Microsoft.AspNetCore.Http;`
|  | `8` |  | `#endif`
|  | `9` |  | ``
|  | `10` |  | `namespace WireMock.Owin`
|  | `11` |  | `{`
|  | `12` |  | `#if !USE_ASPNETCORE`
|  | `13` |  | `internal class GlobalExceptionMiddleware : OwinMiddleware`
|  | `14` |  | `#else`
|  | `15` |  | `internal class GlobalExceptionMiddleware`
|  | `16` |  | `#endif`
|  | `17` |  | `{`
|  | `18` |  | `private readonly WireMockMiddlewareOptions _options;`
|  | `19` |  | ``
|  | `20` |  | `#if !USE_ASPNETCORE`
|  | `21` |  | `public GlobalExceptionMiddleware(OwinMiddleware next, WireMockMiddlewareOptions options) : base(next)`
|  | `22` |  | `{`
|  | `23` |  | `_options = options;`
|  | `24` |  | `}`
|  | `25` |  | `#else`
| 55 | `26` |  | `public GlobalExceptionMiddleware(RequestDelegate next, WireMockMiddlewareOptions options)`
| 55 | `27` |  | `{`
| 55 | `28` |  | `Next = next;`
| 55 | `29` |  | `_options = options;`
| 55 | `30` |  | `}`
|  | `31` |  | `#endif`
|  | `32` |  | ``
|  | `33` |  | `#if USE_ASPNETCORE`
| 65 | `34` |  | `public RequestDelegate Next { get; }`
|  | `35` |  | `#endif`
|  | `36` |  | ``
| 55 | `37` |  | `private readonly OwinResponseMapper _responseMapper = new OwinResponseMapper();`
|  | `38` |  | ``
|  | `39` |  | `#if !USE_ASPNETCORE`
|  | `40` |  | `public override async Task Invoke(IOwinContext ctx)`
|  | `41` |  | `#else`
|  | `42` |  | `public async Task Invoke(HttpContext ctx)`
|  | `43` |  | `#endif`
| 65 | `44` |  | `{`
|  | `45` |  | `try`
| 65 | `46` |  | `{`
| 65 | `47` |  | `await Next?.Invoke(ctx);`
| 65 | `48` |  | `}`
| 0 | `49` |  | `catch (Exception ex)`
| 0 | `50` |  | `{`
| 0 | `51` |  | `_options.Logger.Error("HttpStatusCode set to 500 {0}", ex);`
| 0 | `52` |  | `await _responseMapper.MapAsync(ResponseMessageBuilder.Create(JsonConvert.SerializeObject(ex), 500), ctx.`
| 0 | `53` |  | `}`
| 65 | `54` |  | `}`
|  | `55` |  | `}`
|  | `56` |  | `}`

# Methods/Properties

.ctor(Microsoft.AspNetCore.Http.RequestDelegate,WireMock.Owin.WireMockMiddlewareOptions)
Next()
Invoke()