mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fixed error message parsing in r5net.
This commit is contained in:
parent
64aa6e7f97
commit
4f463eb446
@ -51,9 +51,25 @@ std::vector<ServerListing> R5Net::Client::GetServersList(std::string& outMessage
|
||||
else
|
||||
{
|
||||
if (res)
|
||||
{
|
||||
if (!res->body.empty())
|
||||
{
|
||||
nlohmann::json resBody = nlohmann::json::parse(res->body);
|
||||
|
||||
if (resBody["err"].is_string())
|
||||
outMessage = resBody["err"].get<std::string>();
|
||||
else
|
||||
outMessage = std::string("Failed to reach comp-server ") + std::to_string(res->status);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
outMessage = std::string("Failed to reach comp-server ") + std::to_string(res->status);
|
||||
else
|
||||
outMessage = "Failed to reach comp-server unknown error code.";
|
||||
return list;
|
||||
}
|
||||
|
||||
outMessage = "failed to reach comp-server unknown error code.";
|
||||
return list;
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -107,12 +123,24 @@ bool R5Net::Client::PostServerHost(std::string& outMessage, std::string& outToke
|
||||
else
|
||||
{
|
||||
if (res)
|
||||
{
|
||||
if (!res->body.empty())
|
||||
{
|
||||
nlohmann::json resBody = nlohmann::json::parse(res->body);
|
||||
|
||||
if (resBody["err"].is_string())
|
||||
outMessage = resBody["err"].get<std::string>();
|
||||
else
|
||||
outMessage = std::string("Failed to reach comp-server ") + std::to_string(res->status);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
outMessage = std::string("Failed to reach comp-server ") + std::to_string(res->status);
|
||||
else
|
||||
outMessage = "Failed to reach comp-server unknown error code.";
|
||||
|
||||
outToken = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
outMessage = "failed to reach comp-server unknown error code.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -175,7 +203,7 @@ bool R5Net::Client::GetServerByToken(ServerListing& outServer, std::string& outM
|
||||
if (resBody["err"].is_string())
|
||||
outMessage = resBody["err"].get<std::string>();
|
||||
else
|
||||
outMessage = "Failed to reach comp-server unknown error code.";
|
||||
outMessage = std::string("Failed to reach comp-server ") + std::to_string(res->status);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user