Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement of error handling capabilities #56

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/MLS.Api/Middleware/ExceptionMiddleware.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -53,6 +54,7 @@ private async Task HandleExceptionAsync(HttpContext httpContext, Exception ex)
Detail = notFound.InnerException?.Message
};
break;

default:
problem = new CustomProblemDetails
{
Expand Down
11 changes: 5 additions & 6 deletions src/MLS.Api/Models/CustomProblemDetails.cs
Original file line number Diff line number Diff line change
@@ -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<string, string[]> Errors { get; set; } = new Dictionary<string, string[]>();
}
}
public IDictionary<string, string[]> Errors { get; set; } = new Dictionary<string, string[]>();
}
Loading