mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: log error when globally ratelimited
This commit is contained in:
parent
32a73eef09
commit
078b5a5bcd
1 changed files with 13 additions and 1 deletions
|
|
@ -191,7 +191,7 @@ public class BaseRestClient: IAsyncDisposable
|
|||
catch (Exception exc)
|
||||
{
|
||||
_logger.Error(exc, "HTTP error: {RequestMethod} {RequestUrl}", request.Method,
|
||||
request.RequestUri);
|
||||
CleanForLogging(request.RequestUri!));
|
||||
|
||||
// kill the running thread
|
||||
// in PluralKit.Bot, this error is ignored in "IsOurProblem" (PluralKit.Bot/Utils/MiscUtils.cs)
|
||||
|
|
@ -232,6 +232,18 @@ public class BaseRestClient: IAsyncDisposable
|
|||
var apiError = TryParseApiError(body);
|
||||
if (apiError != null)
|
||||
{
|
||||
string? xRateLimitScope = "";
|
||||
|
||||
try
|
||||
{
|
||||
var ratelimitHeader = response.Headers.FirstOrDefault(x => x.Key == "x-ratelimit-scope");
|
||||
xRateLimitScope = ratelimitHeader.Value.FirstOrDefault();
|
||||
if (xRateLimitScope == "global")
|
||||
_logger.Error("We are globally ratelimited!");
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
using var __ = LogContext.PushProperty("RatelimitScope", xRateLimitScope);
|
||||
using var _ = LogContext.PushProperty("DiscordErrorBody", body);
|
||||
_logger.Warning("Discord API error: {DiscordErrorCode} {DiscordErrorMessage}", apiError.Code,
|
||||
apiError.Message);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue