fix(apiv2): correctly parse timestamp in SwitchPatch

This commit is contained in:
spiral
2021-10-13 08:59:42 -04:00
parent 098d804344
commit 431f7e8931
2 changed files with 8 additions and 3 deletions

View File

@@ -140,7 +140,10 @@ 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"))
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"))
)
{
ctx.Response.StatusCode = 400;
await ctx.Response.WriteAsync("{\"message\":\"400: Bad Request\",\"code\":0}");