diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-06-11 07:50:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-06-11 07:50:08 +0900 |
commit | cee574090838ab54961d2d34b76d60964f7a8304 (patch) | |
tree | 4ef79451ec35d32008229652941ce1956d229343 | |
parent | c5f469375f7c7b09f5f5c9a13ca07c6cf7c2b68a (diff) | |
download | libquotient-cee574090838ab54961d2d34b76d60964f7a8304.tar.gz libquotient-cee574090838ab54961d2d34b76d60964f7a8304.zip |
BaseJob: Drop 'error' from methods that work in normal job state too
-rw-r--r-- | lib/connection.cpp | 8 | ||||
-rw-r--r-- | lib/jobs/basejob.cpp | 14 | ||||
-rw-r--r-- | lib/jobs/basejob.h | 14 |
3 files changed, 23 insertions, 13 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index a4980140..29bb9564 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -198,7 +198,7 @@ void Connection::doConnectToServer(const QString& user, const QString& password, }); connect(loginJob, &BaseJob::failure, this, [this, loginJob] { - emit loginError(loginJob->errorString(), loginJob->errorRawData()); + emit loginError(loginJob->errorString(), loginJob->rawData()); }); } @@ -274,7 +274,7 @@ void Connection::sync(int timeout) connect( job, &SyncJob::retryScheduled, this, [this,job] (int retriesTaken, int nextInMilliseconds) { - emit networkError(job->errorString(), job->errorRawData(), + emit networkError(job->errorString(), job->rawData(), retriesTaken, nextInMilliseconds); }); connect( job, &SyncJob::failure, this, [this, job] { @@ -283,10 +283,10 @@ void Connection::sync(int timeout) { qCWarning(SYNCJOB) << "Sync job failed with ContentAccessError - login expired?"; - emit loginError(job->errorString(), job->errorRawData()); + emit loginError(job->errorString(), job->rawData()); } else - emit syncError(job->errorString(), job->errorRawData()); + emit syncError(job->errorString(), job->rawData()); }); } diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 6984f16f..2a6705b8 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -509,12 +509,12 @@ BaseJob::Status BaseJob::status() const return d->status; } -int BaseJob::error() const +QByteArray BaseJob::rawData() const { - return d->status.code; + return d->rawResponse; } -QString BaseJob::errorCaption() const +QString BaseJob::statusCaption() const { switch (d->status.code) { @@ -553,14 +553,14 @@ QString BaseJob::errorCaption() const } } -QString BaseJob::errorString() const +int BaseJob::error() const { - return d->status.message; + return d->status.code; } -QByteArray BaseJob::errorRawData() const +QString BaseJob::errorString() const { - return d->rawResponse; + return d->status.message; } QUrl BaseJob::errorUrl() const diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index 0d791d3a..c34ba3c3 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -134,11 +134,21 @@ namespace QMatrixClient QUrl requestUrl() const; bool isBackground() const; + /** Current status of the job */ Status status() const; + /** Short human-friendly message on the job status */ + QString statusCaption() const; + /** Raw response body as received from the server */ + QByteArray rawData() const; + + /** Error (more generally, status) code + * Equivalent to status().code + * \sa status + */ int error() const; - QString errorCaption() const; + /** Error-specific message, as returned by the server */ virtual QString errorString() const; - QByteArray errorRawData() const; + /** A URL to help/clarify the error, if provided by the server */ QUrl errorUrl() const; int maxRetries() const; |