diff --git a/src/Discord.Net.Core/Net/HttpException.cs b/src/Discord.Net.Core/Net/HttpException.cs index 07551f0e7..b026bc6f1 100644 --- a/src/Discord.Net.Core/Net/HttpException.cs +++ b/src/Discord.Net.Core/Net/HttpException.cs @@ -49,7 +49,7 @@ namespace Discord.Net /// The Discord status code returned. /// The reason behind the exception. public HttpException(HttpStatusCode httpCode, IRequest request, DiscordErrorCode? discordCode = null, string reason = null, DiscordJsonError[] errors = null) - : base(CreateMessage(httpCode, (int?)discordCode, reason)) + : base(CreateMessage(httpCode, (int?)discordCode, reason, errors)) { HttpCode = httpCode; Request = request; @@ -58,8 +58,8 @@ namespace Discord.Net Errors = errors?.ToImmutableArray() ?? ImmutableArray.Empty; } - private static string CreateMessage(HttpStatusCode httpCode, int? discordCode = null, string reason = null) - { + private static string CreateMessage(HttpStatusCode httpCode, int? discordCode = null, string reason = null, DiscordJsonError[] errors = null) + { string msg; if (discordCode != null && discordCode != 0) { @@ -75,6 +75,16 @@ namespace Discord.Net else msg = $"The server responded with error {(int)httpCode}: {httpCode}"; } + + if (errors?.Length > 0) + { + msg += "\nInner Errors:"; + foreach (var error in errors) + if (error.Errors?.Count > 0) + foreach (var innerError in error.Errors) + msg += $"\n{innerError.Code}: {innerError.Message}"; + } + return msg; } }