Skip to content

Commit

Permalink
Print path in request errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yourWaifu committed Feb 12, 2022
1 parent 94d5ed5 commit f71b6f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/sleepy_discord/rate_limiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace SleepyDiscord {
inline operator const std::string&() {
return url();
}
inline const std::string& getPath() {
return path;
}

private:
const std::string path;
Expand Down
4 changes: 4 additions & 0 deletions sleepy_discord/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,17 @@ namespace SleepyDiscord {
auto errorMessage = document.FindMember("message");
if (errorCode != document.MemberEnd()) {
std::size_t fullErrorMessageSize = 0;
fullErrorMessageSize += path.getPath().length();
fullErrorMessageSize += 1;
fullErrorMessageSize += response.text.length();
fullErrorMessageSize += 1;
std::string message =
(errorMessage != document.MemberEnd() ? errorMessage->value.GetString() : "");
fullErrorMessageSize += message.length();
std::string fullErrorMessage;
fullErrorMessage.reserve(fullErrorMessageSize);
fullErrorMessage += path.getPath();
fullErrorMessage += '\n';
fullErrorMessage += response.text;
fullErrorMessage += '\n';
fullErrorMessage += message;
Expand Down

0 comments on commit f71b6f5

Please sign in to comment.