Improve network error messages (#4704)

This commit is contained in:
nerix
2023-07-01 14:59:59 +02:00
committed by GitHub
parent d2f1516818
commit 22b290cb2d
15 changed files with 378 additions and 169 deletions
+8 -5
View File
@@ -155,7 +155,8 @@ void loadUncached(std::shared_ptr<NetworkData> &&data)
{
postToThread([data] {
data->onError_(NetworkResult(
{}, NetworkResult::timedoutStatus));
NetworkResult::NetworkError::TimeoutError, {},
{}));
});
}
@@ -218,8 +219,9 @@ void loadUncached(std::shared_ptr<NetworkData> &&data)
QString(data->payload_));
}
// TODO: Should this always be run on the GUI thread?
postToThread([data, code = status.toInt(), reply] {
data->onError_(NetworkResult(reply->readAll(), code));
postToThread([data, status, reply] {
data->onError_(NetworkResult(reply->error(), status,
reply->readAll()));
});
}
@@ -238,7 +240,7 @@ void loadUncached(std::shared_ptr<NetworkData> &&data)
auto status =
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
NetworkResult result(bytes, status.toInt());
NetworkResult result(reply->error(), status, bytes);
DebugCount::increase("http request success");
// log("starting {}", data->request_.url().toString());
@@ -337,7 +339,8 @@ void loadCached(std::shared_ptr<NetworkData> &&data)
// XXX: check if bytes is empty?
QByteArray bytes = cachedFile.readAll();
NetworkResult result(bytes, 200);
NetworkResult result(NetworkResult::NetworkError::NoError, QVariant(200),
bytes);
qCDebug(chatterinoHTTP)
<< QString("%1 [CACHED] 200 %2")