More Polish (#4098)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
Joe Milazzo
2025-10-14 09:25:15 -05:00
committed by GitHub
parent 91a7e189ce
commit dbd2250bb4
13 changed files with 93 additions and 29 deletions
+7 -7
View File
@@ -11,6 +11,12 @@ namespace API.Middleware;
public class ExceptionMiddleware(RequestDelegate next, ILogger<ExceptionMiddleware> logger)
{
private static readonly JsonSerializerOptions ExceptionJsonSerializeOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
public async Task InvokeAsync(HttpContext context)
{
try
@@ -27,13 +33,7 @@ public class ExceptionMiddleware(RequestDelegate next, ILogger<ExceptionMiddlewa
var response = new ApiException(context.Response.StatusCode, errorMessage, ex.StackTrace);
var options = new JsonSerializerOptions
{
PropertyNamingPolicy =
JsonNamingPolicy.CamelCase
};
var json = JsonSerializer.Serialize(response, options);
var json = JsonSerializer.Serialize(response, ExceptionJsonSerializeOptions);
await context.Response.WriteAsync(json);