@@ -144,21 +144,26 @@ void HttpLogger::logRequest(QNetworkReply *reply, QNetworkAccessManager::Operati
144
144
return ;
145
145
}
146
146
147
+ const auto logError = [reply, operation]() {
148
+ auto url = reply->request ().url ();
149
+ qCInfo (lcNetworkHttp).noquote ().nospace () << " An error occurred for " << url.toDisplayString () << " : " << reply->errorString () << " (" << reply->error ()
150
+ << " , " << operation << " )" ;
151
+ };
152
+
147
153
auto ctx = std::make_unique<HttpContext>(reply->request ());
148
154
149
155
// device should still exist, lets still use a qpointer to ensure we have valid data
150
- const auto logSend = [ctx = ctx.get (), operation, reply, device = QPointer<QIODevice>(device), deviceRaw = device](bool cached = false ) {
156
+ const auto logSend = [ctx = ctx.get (), operation, reply, device = QPointer<QIODevice>(device), deviceRaw = device, logError ](bool cached = false ) {
151
157
Q_ASSERT (!deviceRaw || device);
152
158
if (!ctx->send ) {
153
159
ctx->send = true ;
154
160
ctx->timer .reset ();
155
- } else {
161
+ } else if (ctx-> lastUrl != reply-> url ()) {
156
162
// this is a redirect
157
- if (ctx->lastUrl != reply->url ()) {
158
- ctx->addRedirect (reply->url ());
159
- } else {
160
- Q_UNREACHABLE ();
161
- }
163
+ ctx->addRedirect (reply->url ());
164
+ } else {
165
+ // Probably an error (time-out?).
166
+ logError ();
162
167
}
163
168
164
169
const auto request = reply->request ();
@@ -169,6 +174,7 @@ void HttpLogger::logRequest(QNetworkReply *reply, QNetworkAccessManager::Operati
169
174
logHttp (requestVerb (operation, request), ctx, std::move (header), device, cached);
170
175
};
171
176
QObject::connect (reply, &QNetworkReply::requestSent, reply, logSend, Qt::DirectConnection);
177
+ QObject::connect (reply, &QNetworkReply::errorOccurred, reply, logError, Qt::DirectConnection);
172
178
173
179
174
180
QObject::connect (
0 commit comments