diff --git a/PluralKit.API/Startup.cs b/PluralKit.API/Startup.cs index f14dafba..67626ffa 100644 --- a/PluralKit.API/Startup.cs +++ b/PluralKit.API/Startup.cs @@ -133,6 +133,15 @@ namespace PluralKit.API app.UseExceptionHandler(handler => handler.Run(async ctx => { var exc = ctx.Features.Get(); + + // handle common ISEs that are generated by invalid user input + if (exc.Error is InvalidCastException && exc.Error.Message.Contains("Newtonsoft.Json")) + { + ctx.Response.StatusCode = 400; + await ctx.Response.WriteAsync("{\"message\":\"400: Bad Request\",\"code\":0}"); + return; + } + if (exc.Error is not PKError) { ctx.Response.StatusCode = 500;