mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix: asp.net doesn't automatically complete the response writer
This commit is contained in:
parent
e1a5310a3a
commit
bdb6b61903
1 changed files with 11 additions and 10 deletions
|
|
@ -148,30 +148,31 @@ namespace PluralKit.API
|
|||
{
|
||||
ctx.Response.StatusCode = 400;
|
||||
await ctx.Response.WriteAsync("{\"message\":\"400: Bad Request\",\"code\":0}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (exc.Error is not PKError)
|
||||
else if (exc.Error is not PKError)
|
||||
{
|
||||
ctx.Response.StatusCode = 500;
|
||||
await ctx.Response.WriteAsync("{\"message\":\"500: Internal Server Error\",\"code\":0}");
|
||||
return;
|
||||
}
|
||||
|
||||
// for some reason, if we don't specifically cast to ModelParseError, it uses the base's ToJson method
|
||||
if (exc.Error is ModelParseError fe)
|
||||
else if (exc.Error is ModelParseError fe)
|
||||
{
|
||||
ctx.Response.StatusCode = fe.ResponseCode;
|
||||
await ctx.Response.WriteAsync(JsonConvert.SerializeObject(fe.ToJson()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var err = (PKError)exc.Error;
|
||||
ctx.Response.StatusCode = err.ResponseCode;
|
||||
else
|
||||
{
|
||||
var err = (PKError)exc.Error;
|
||||
ctx.Response.StatusCode = err.ResponseCode;
|
||||
|
||||
var json = JsonConvert.SerializeObject(err.ToJson());
|
||||
await ctx.Response.WriteAsync(json);
|
||||
var json = JsonConvert.SerializeObject(err.ToJson());
|
||||
await ctx.Response.WriteAsync(json);
|
||||
}
|
||||
|
||||
await ctx.Response.CompleteAsync();
|
||||
}));
|
||||
|
||||
app.UseMiddleware<AuthorizationTokenHandlerMiddleware>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue