diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-23 16:39:25 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-23 16:42:40 +0900 |
commit | 73fec4b25d81b73f25309bfb3e274df7553341ea (patch) | |
tree | ffa03b0f82bfc092c4316192fd5e849a92a1193f /lib/connection.cpp | |
parent | 79403a004129852af10f0a7d9b8dca0276724d28 (diff) | |
download | libquotient-73fec4b25d81b73f25309bfb3e274df7553341ea.tar.gz libquotient-73fec4b25d81b73f25309bfb3e274df7553341ea.zip |
BaseJob: more careful error handling; unify and extend error signals in Connection
(Note: this commit breaks back-compatibility.)
BaseJob::gotReply() had a bold assumption that whenever there's no reasonable JSON body in case of error, that meant IncorrectRequestError (which of course was incorrect). This led to syncs dying in Quaternion because it (correctly) considered IncorrectRequestError to be grave enough to not retry. Closes #206.
Also: don't dump the whole payload to logs, limit with initial 500 characters (closes #205)
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r-- | lib/connection.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index f21d6973..84557224 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -196,7 +196,7 @@ void Connection::doConnectToServer(const QString& user, const QString& password, }); connect(loginJob, &BaseJob::failure, this, [this, loginJob] { - emit loginError(loginJob->errorString()); + emit loginError(loginJob->errorString(), loginJob->errorDetails()); }); } @@ -269,13 +269,18 @@ void Connection::sync(int timeout) d->syncJob = nullptr; emit syncDone(); }); - connect( job, &SyncJob::retryScheduled, this, &Connection::networkError); + connect( job, &SyncJob::retryScheduled, this, + [this,job] (int retriesTaken, int nextInMilliseconds) + { + emit networkError(job->errorString(), job->errorDetails(), + retriesTaken, nextInMilliseconds); + }); connect( job, &SyncJob::failure, this, [this, job] { d->syncJob = nullptr; if (job->error() == BaseJob::ContentAccessError) - emit loginError(job->errorString()); + emit loginError(job->errorString(), job->errorDetails()); else - emit syncError(job->errorString()); + emit syncError(job->errorString(), job->errorDetails()); }); } |