# 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: | 10
Uncovered lines: | 4
Coverable lines: | 14
Total lines: | 56
Line coverage: | 71.4%
Branch coverage: | 66.6%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
.ctor(...) | 1 | 0 | 100 | 100
Invoke() | 9 | 8 | 55.56 | 71.43

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

# Methods/Properties

.ctor(Microsoft.Owin.OwinMiddleware,WireMock.Owin.WireMockMiddlewareOptions)
Invoke()