From f702167d6ef99432d3585498469a3f78cff4748d Mon Sep 17 00:00:00 2001
From: Masu-Baumgartner <68913099+Masu-Baumgartner@users.noreply.github.com>
Date: Thu, 21 Nov 2024 09:41:53 +0100
Subject: [PATCH] Fixed api exception handler
---
Moonlight.ApiServer/Moonlight.ApiServer.csproj | 2 +-
Moonlight.ApiServer/Startup.cs | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Moonlight.ApiServer/Moonlight.ApiServer.csproj b/Moonlight.ApiServer/Moonlight.ApiServer.csproj
index e0c5d23d..7fb008e8 100644
--- a/Moonlight.ApiServer/Moonlight.ApiServer.csproj
+++ b/Moonlight.ApiServer/Moonlight.ApiServer.csproj
@@ -24,7 +24,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/Moonlight.ApiServer/Startup.cs b/Moonlight.ApiServer/Startup.cs
index ebf4f374..62ec15b1 100644
--- a/Moonlight.ApiServer/Startup.cs
+++ b/Moonlight.ApiServer/Startup.cs
@@ -129,6 +129,7 @@ public class Startup
{
WebApplicationBuilder.Services.AutoAddServices();
WebApplicationBuilder.Services.AddHttpClient();
+
WebApplicationBuilder.Services.AddApiExceptionHandler();
// Add pre-existing services
@@ -151,7 +152,7 @@ public class Startup
private Task UseBase()
{
WebApplication.UseRouting();
- WebApplication.UseExceptionHandler("/");
+ WebApplication.UseApiExceptionHandler();
if (Configuration.Client.Enable)
{
@@ -447,6 +448,11 @@ public class Startup
"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware",
LogLevel.Critical
);
+
+ WebApplicationBuilder.Logging.AddFilter(
+ "Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware",
+ LogLevel.Critical
+ );
}
#endregion