diff --git a/src/MLS.Api/Middleware/ExceptionMiddleware.cs b/src/MLS.Api/Middleware/ExceptionMiddleware.cs index dc4c3be..bcc57cd 100644 --- a/src/MLS.Api/Middleware/ExceptionMiddleware.cs +++ b/src/MLS.Api/Middleware/ExceptionMiddleware.cs @@ -1,6 +1,6 @@ -using System.Net; -using MLS.Api.Models; +using MLS.Api.Models; using MLS.Application.Exceptions; +using System.Net; namespace MLS.Api.Middleware; @@ -43,6 +43,7 @@ private async Task HandleExceptionAsync(HttpContext httpContext, Exception ex) Errors = badRequestException.ValidationErrors }; break; + case NotFoundException notFound: statusCode = HttpStatusCode.NotFound; problem = new CustomProblemDetails @@ -53,6 +54,7 @@ private async Task HandleExceptionAsync(HttpContext httpContext, Exception ex) Detail = notFound.InnerException?.Message }; break; + default: problem = new CustomProblemDetails { diff --git a/src/MLS.Api/Models/CustomProblemDetails.cs b/src/MLS.Api/Models/CustomProblemDetails.cs index 813217e..0c92d3e 100644 --- a/src/MLS.Api/Models/CustomProblemDetails.cs +++ b/src/MLS.Api/Models/CustomProblemDetails.cs @@ -1,9 +1,8 @@ using Microsoft.AspNetCore.Mvc; -namespace MLS.Api.Models +namespace MLS.Api.Models; + +public class CustomProblemDetails : ProblemDetails { - public class CustomProblemDetails : ProblemDetails - { - public IDictionary Errors { get; set; } = new Dictionary(); - } -} + public IDictionary Errors { get; set; } = new Dictionary(); +} \ No newline at end of file