refactor(apiv2): rename APIErrors to Errors, move IsUserError to helper method

This commit is contained in:
spiral
2021-10-13 09:08:17 -04:00
parent 431f7e8931
commit fd49e7e4ea
9 changed files with 98 additions and 84 deletions

View File

@@ -140,10 +140,7 @@ namespace PluralKit.API
var exc = ctx.Features.Get<IExceptionHandlerPathFeature>();
// handle common ISEs that are generated by invalid user input
if (
(exc.Error is InvalidCastException && exc.Error.Message.Contains("Newtonsoft.Json"))
|| (exc.Error is FormatException && exc.Error.Message.Contains("was not recognized as a valid DateTime"))
)
if (exc.Error.IsUserError())
{
ctx.Response.StatusCode = 400;
await ctx.Response.WriteAsync("{\"message\":\"400: Bad Request\",\"code\":0}");