Logging: Avoid the word "Error"

The old code printed "QNetworkReply::NoError"
This commit is contained in:
Markus Goetz 2018-04-17 20:21:49 +02:00 committed by Roeland Jago Douma
parent ba901503fc
commit 367d0c39e8
No known key found for this signature in database
GPG key ID: F941078878347C0C
7 changed files with 22 additions and 20 deletions

View file

@ -27,6 +27,7 @@
#include <QMutex>
#include <QCoreApplication>
#include <QAuthenticator>
#include <QMetaEnum>
#include "networkjobs.h"
#include "account.h"
@ -308,6 +309,15 @@ void AbstractNetworkJob::onTimedOut()
}
}
QString AbstractNetworkJob::replyStatusString() {
Q_ASSERT(reply());
if (reply()->error() == QNetworkReply::NoError) {
return QLatin1String("OK");
} else {
QString enumStr = QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(static_cast<int>(reply()->error()));
return QStringLiteral("%1 %2").arg(enumStr, errorString());
}
}
NetworkJobTimeoutPauser::NetworkJobTimeoutPauser(QNetworkReply *reply)
{

View file

@ -173,6 +173,8 @@ protected:
// GET requests that don't set up any HTTP body or other flags.
bool _followRedirects;
QString replyStatusString();
private slots:
void slotFinished();
void slotTimeout();

View file

@ -92,8 +92,7 @@ void RequestEtagJob::start()
bool RequestEtagJob::finished()
{
qCInfo(lcEtagJob) << "Request Etag of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
if (reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 207) {
// Parse DAV response
@ -150,8 +149,7 @@ void MkColJob::start()
bool MkColJob::finished()
{
qCInfo(lcMkColJob) << "MKCOL of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
emit finished(reply()->error());
return true;
@ -359,8 +357,7 @@ void LsColJob::start()
bool LsColJob::finished()
{
qCInfo(lcLsColJob) << "LSCOL of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
QString contentType = reply()->header(QNetworkRequest::ContentTypeHeader).toString();
int httpCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
@ -586,8 +583,7 @@ QList<QByteArray> PropfindJob::properties() const
bool PropfindJob::finished()
{
qCInfo(lcPropfindJob) << "PROPFIND of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
@ -748,8 +744,7 @@ QMap<QByteArray, QByteArray> ProppatchJob::properties() const
bool ProppatchJob::finished()
{
qCInfo(lcProppatchJob) << "PROPPATCH of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
@ -812,8 +807,7 @@ void JsonApiJob::start()
bool JsonApiJob::finished()
{
qCInfo(lcJsonApiJob) << "JsonApiJob of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
int statusCode = 0;
int httpStatusCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();

View file

@ -313,8 +313,7 @@ void GETFileJob::slotReadyRead()
}
if (!_hasEmittedFinishedSignal) {
qCInfo(lcGetJob) << "GET of" << reply()->request().url().toString() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString())
<< replyStatusString()
<< reply()->rawHeader("Content-Range") << reply()->rawHeader("Content-Length");
emit finishedSignal();

View file

@ -54,8 +54,7 @@ void DeleteJob::start()
bool DeleteJob::finished()
{
qCInfo(lcDeleteJob) << "DELETE of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
emit finishedSignal();
return true;

View file

@ -67,8 +67,7 @@ void MoveJob::start()
bool MoveJob::finished()
{
qCInfo(lcMoveJob) << "MOVE of" << reply()->request().url() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
<< replyStatusString();
emit finishedSignal();
return true;

View file

@ -120,8 +120,7 @@ public:
virtual bool finished() Q_DECL_OVERRIDE
{
qCInfo(lcPutJob) << "PUT of" << reply()->request().url().toString() << "FINISHED WITH STATUS"
<< reply()->error()
<< (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString())
<< replyStatusString()
<< reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute)
<< reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute);