Include network response body in errors (#3987)

This commit is contained in:
pajlada 2022-09-11 14:32:08 +02:00 committed by GitHub
parent 7337e93a27
commit 5655a7d718
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -60,6 +60,7 @@
- Dev: Use Game Name returned by Get Streams instead of querying it from the Get Games API. (#3662) - Dev: Use Game Name returned by Get Streams instead of querying it from the Get Games API. (#3662)
- Dev: Batch checking live status for all channels after startup. (#3757, #3762, #3767) - Dev: Batch checking live status for all channels after startup. (#3757, #3762, #3767)
- Dev: Move most command context into the command controller. (#3824) - Dev: Move most command context into the command controller. (#3824)
- Dev: Error NetworkResults now include the body data. (#3987)
## 2.3.5 ## 2.3.5

View file

@ -218,8 +218,8 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
QString(data->payload_)); QString(data->payload_));
} }
// TODO: Should this always be run on the GUI thread? // TODO: Should this always be run on the GUI thread?
postToThread([data, code = status.toInt()] { postToThread([data, code = status.toInt(), reply] {
data->onError_(NetworkResult({}, code)); data->onError_(NetworkResult(reply->readAll(), code));
}); });
} }

View file

@ -145,6 +145,11 @@ TEST(NetworkRequest, Error)
.onError([code, &mut, &requestDone, &requestDoneCondition, .onError([code, &mut, &requestDone, &requestDoneCondition,
url](NetworkResult result) { url](NetworkResult result) {
EXPECT_EQ(result.status(), code); EXPECT_EQ(result.status(), code);
if (code == 402)
{
EXPECT_EQ(result.getData(),
QString("Fuck you, pay me!").toUtf8());
}
{ {
std::unique_lock lck(mut); std::unique_lock lck(mut);