diff options
| author | transtrike <transtrike@gmail.com> | 2021-02-13 16:20:18 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-02-13 16:20:18 +0200 |
| commit | 98e17766b203734a1817eed94338e2d25f4395f7 (patch) | |
| tree | 1266385a56cba56fd55c7faf661dd844bbdf5705 /src/DevHive.Web/Middleware | |
| parent | 1ab34accfda22ee3ce5c7700e3b97ff3e932d649 (diff) | |
| download | DevHive-98e17766b203734a1817eed94338e2d25f4395f7.tar DevHive-98e17766b203734a1817eed94338e2d25f4395f7.tar.gz DevHive-98e17766b203734a1817eed94338e2d25f4395f7.zip | |
Project Restructure P.1
Diffstat (limited to 'src/DevHive.Web/Middleware')
| -rw-r--r-- | src/DevHive.Web/Middleware/ExceptionMiddleware.cs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/DevHive.Web/Middleware/ExceptionMiddleware.cs b/src/DevHive.Web/Middleware/ExceptionMiddleware.cs deleted file mode 100644 index cb6d4ca..0000000 --- a/src/DevHive.Web/Middleware/ExceptionMiddleware.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Net; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; - -namespace DevHive.Web.Middleware -{ - public class ExceptionMiddleware - { - private readonly RequestDelegate _next; - // private readonly ILogger _logger; - - public ExceptionMiddleware(RequestDelegate next) - { - this._next = next; - // this._logger = logger; - } - // public ExceptionMiddleware(RequestDelegate next, ILogger logger) - // { - // this._logger = logger; - // this._next = next; - // } - - public async Task InvokeAsync(HttpContext httpContext) - { - try - { - await this._next(httpContext); - } - catch (Exception ex) - { - // this._logger.LogError($"Something went wrong: {ex}"); - await HandleExceptionAsync(httpContext, ex); - } - } - - private Task HandleExceptionAsync(HttpContext context, Exception exception) - { - context.Response.ContentType = "application/json"; - context.Response.StatusCode = (int)HttpStatusCode.BadRequest; - - return context.Response.WriteAsync(new - { - StatusCode = context.Response.StatusCode, - Message = exception.Message - }.ToString()); - } - } -} |
