From c3e9d39034e5afc3f2c3a12c8c7682eabe360b7d Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Fri, 29 May 2026 22:35:18 +1000 Subject: Modified controller endpoints to throw exceptions instead of returning HTTP responses on error --- ExceptionMiddleware.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ExceptionMiddleware.cs') diff --git a/ExceptionMiddleware.cs b/ExceptionMiddleware.cs index 29d0e10..ba4049a 100644 --- a/ExceptionMiddleware.cs +++ b/ExceptionMiddleware.cs @@ -23,16 +23,16 @@ public sealed class ExceptionMiddleware { e.GetType().GetCustomAttribute()?.StatusCode ?? StatusCodes.Status500InternalServerError; - await context.Response.WriteAsJsonAsync(e); + context.Response.Clear(); - var x = 1; + await context.Response.WriteAsJsonAsync(e); } catch(Exception) { context.Response.StatusCode = StatusCodes.Status500InternalServerError; context.Response.ContentType = "application/json"; context.Response.Clear(); - await context.Response.WriteAsync(string.Empty); + await context.Response.WriteAsJsonAsync(new ServerException()); } } } -- cgit v1.3