option to dump gw payloads on errors (#2999)
* option to dump gw payloads on errors * w a r n i n g
This commit is contained in:
@@ -83,6 +83,7 @@ namespace Discord.WebSocket
|
|||||||
internal bool AlwaysResolveStickers { get; private set; }
|
internal bool AlwaysResolveStickers { get; private set; }
|
||||||
internal bool LogGatewayIntentWarnings { get; private set; }
|
internal bool LogGatewayIntentWarnings { get; private set; }
|
||||||
internal bool SuppressUnknownDispatchWarnings { get; private set; }
|
internal bool SuppressUnknownDispatchWarnings { get; private set; }
|
||||||
|
internal bool IncludeRawPayloadOnGatewayErrors { get; private set; }
|
||||||
internal int AuditLogCacheSize { get; private set; }
|
internal int AuditLogCacheSize { get; private set; }
|
||||||
|
|
||||||
internal new DiscordSocketApiClient ApiClient => base.ApiClient;
|
internal new DiscordSocketApiClient ApiClient => base.ApiClient;
|
||||||
@@ -158,6 +159,7 @@ namespace Discord.WebSocket
|
|||||||
AlwaysResolveStickers = config.AlwaysResolveStickers;
|
AlwaysResolveStickers = config.AlwaysResolveStickers;
|
||||||
LogGatewayIntentWarnings = config.LogGatewayIntentWarnings;
|
LogGatewayIntentWarnings = config.LogGatewayIntentWarnings;
|
||||||
SuppressUnknownDispatchWarnings = config.SuppressUnknownDispatchWarnings;
|
SuppressUnknownDispatchWarnings = config.SuppressUnknownDispatchWarnings;
|
||||||
|
IncludeRawPayloadOnGatewayErrors = config.IncludeRawPayloadOnGatewayErrors;
|
||||||
HandlerTimeout = config.HandlerTimeout;
|
HandlerTimeout = config.HandlerTimeout;
|
||||||
State = new ClientState(0, 0);
|
State = new ClientState(0, 0);
|
||||||
Rest = new DiscordSocketRestClient(config, ApiClient);
|
Rest = new DiscordSocketRestClient(config, ApiClient);
|
||||||
@@ -3342,6 +3344,13 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
if (IncludeRawPayloadOnGatewayErrors)
|
||||||
|
{
|
||||||
|
ex.Data["opcode"] = opCode;
|
||||||
|
ex.Data["type"] = type;
|
||||||
|
ex.Data["payload_data"] = (payload as JToken).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
await _gatewayLogger.ErrorAsync($"Error handling {opCode}{(type != null ? $" ({type})" : "")}", ex).ConfigureAwait(false);
|
await _gatewayLogger.ErrorAsync($"Error handling {opCode}{(type != null ? $" ({type})" : "")}", ex).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,15 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether or not to include the raw payload on gateway errors.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Note that this may expose sensitive information to logs. It is recommended to only enable this in
|
||||||
|
/// cases where you are actively debugging an issue.
|
||||||
|
/// </remarks>
|
||||||
|
public bool IncludeRawPayloadOnGatewayErrors { get; set; } = false;
|
||||||
|
|
||||||
private int maxWaitForGuildAvailable = 10000;
|
private int maxWaitForGuildAvailable = 10000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user