diff options
Diffstat (limited to 'src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs')
| -rw-r--r-- | src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs b/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs index cb6d4ca..f159b69 100644 --- a/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs +++ b/src/Web/DevHive.Web/Middleware/ExceptionMiddleware.cs @@ -9,18 +9,11 @@ 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) { @@ -30,20 +23,19 @@ namespace DevHive.Web.Middleware } catch (Exception ex) { - // this._logger.LogError($"Something went wrong: {ex}"); await HandleExceptionAsync(httpContext, ex); } } - private Task HandleExceptionAsync(HttpContext context, Exception exception) + private static 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 + context.Response.StatusCode, + exception.Message }.ToString()); } } |
