summaryrefslogtreecommitdiff
path: root/ExceptionMiddleware.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2026-05-29 22:35:18 +1000
committerJake Mannens <jake@asger.xyz>2026-05-30 03:38:05 +1000
commitc3e9d39034e5afc3f2c3a12c8c7682eabe360b7d (patch)
tree73c5f43ec246f700a164ef700956b9d82b95f594 /ExceptionMiddleware.cs
parentcfd9959de69f9ab52e846e8acd232dc30d20aa27 (diff)
Modified controller endpoints to throw exceptions instead of returning HTTP responses on error
Diffstat (limited to 'ExceptionMiddleware.cs')
-rw-r--r--ExceptionMiddleware.cs6
1 files changed, 3 insertions, 3 deletions
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<ExceptionStatusCodeAttribute>()?.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());
}
}
}