@@ -49,7 +49,7 @@ public class HttpException : Exception
49
49
/// <param name="discordCode">The Discord status code returned.</param>
50
50
/// <param name="reason">The reason behind the exception.</param>
51
51
public HttpException ( HttpStatusCode httpCode , IRequest request , DiscordErrorCode ? discordCode = null , string reason = null , DiscordJsonError [ ] errors = null )
52
- : base ( CreateMessage ( httpCode , ( int ? ) discordCode , reason ) )
52
+ : base ( CreateMessage ( httpCode , ( int ? ) discordCode , reason , errors ) )
53
53
{
54
54
HttpCode = httpCode ;
55
55
Request = request ;
@@ -58,8 +58,8 @@ public HttpException(HttpStatusCode httpCode, IRequest request, DiscordErrorCode
58
58
Errors = errors ? . ToImmutableArray ( ) ?? ImmutableArray < DiscordJsonError > . Empty ;
59
59
}
60
60
61
- private static string CreateMessage ( HttpStatusCode httpCode , int ? discordCode = null , string reason = null )
62
- {
61
+ private static string CreateMessage ( HttpStatusCode httpCode , int ? discordCode = null , string reason = null , DiscordJsonError [ ] errors = null )
62
+ {
63
63
string msg ;
64
64
if ( discordCode != null && discordCode != 0 )
65
65
{
@@ -75,6 +75,16 @@ private static string CreateMessage(HttpStatusCode httpCode, int? discordCode =
75
75
else
76
76
msg = $ "The server responded with error { ( int ) httpCode } : { httpCode } ";
77
77
}
78
+
79
+ if ( errors ? . Length > 0 )
80
+ {
81
+ msg += "\n Inner Errors:" ;
82
+ foreach ( var error in errors )
83
+ if ( error . Errors ? . Count > 0 )
84
+ foreach ( var innerError in error . Errors )
85
+ msg += $ "\n { innerError . Code } : { innerError . Message } ";
86
+ }
87
+
78
88
return msg ;
79
89
}
80
90
}
0 commit comments