[Pkg-owncloud-commits] [owncloud-client] 128/175: Improve reporting of server error messages. #3220
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 2ed329e025541f9975033b5600ff92887c1587b5
Author: Christian Kamm <kamm at incasoftware.de>
Date: Thu Jun 4 09:44:11 2015 +0200
Improve reporting of server error messages. #3220
In particular the 'unsupported client version' error message
is now visible to the user when trying to connect to a
server that no longer supports the current client version.
---
src/gui/owncloudsetupwizard.cpp | 7 +------
src/libsync/connectionvalidator.cpp | 2 +-
src/libsync/networkjobs.cpp | 10 ++++++++++
src/libsync/networkjobs.h | 3 +++
src/libsync/propagateupload.cpp | 7 +------
5 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp
index 34dd5e2..cd99a70 100644
--- a/src/gui/owncloudsetupwizard.cpp
+++ b/src/gui/owncloudsetupwizard.cpp
@@ -272,12 +272,7 @@ void OwncloudSetupWizard::slotAuthError()
"<a href=\"%1\">click here</a> to access the service with your browser.")
.arg(_ocWizard->account()->url().toString());
} else {
- errorMsg = reply->errorString();
-
- QString extraMsg = extractErrorMessage(reply->readAll());
- if (!extraMsg.isEmpty()) {
- errorMsg.append(QString(" (%1)").arg(extraMsg));
- }
+ errorMsg = errorMessage(reply->errorString(), reply->readAll());
}
// Something else went wrong, maybe the response was 200 but with invalid data.
diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp
index 89e61ed..1c8036f 100644
--- a/src/libsync/connectionvalidator.cpp
+++ b/src/libsync/connectionvalidator.cpp
@@ -187,7 +187,7 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
stat = CredentialsWrong;
} else if( reply->error() != QNetworkReply::NoError ) {
- _errors << reply->errorString();
+ _errors << errorMessage(reply->errorString(), reply->readAll());
const int httpStatus =
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
index 4bdb436..d036a10 100644
--- a/src/libsync/networkjobs.cpp
+++ b/src/libsync/networkjobs.cpp
@@ -868,4 +868,14 @@ QString extractErrorMessage(const QByteArray& errorResponse)
return QString::null;
}
+QString errorMessage(const QString& baseError, const QByteArray& body)
+{
+ QString msg = baseError;
+ QString extra = extractErrorMessage(body);
+ if (!extra.isEmpty()) {
+ msg += QString::fromLatin1(" (%1)").arg(extra);
+ }
+ return msg;
+}
+
} // namespace OCC
diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h
index c78bc43..4f16994 100644
--- a/src/libsync/networkjobs.h
+++ b/src/libsync/networkjobs.h
@@ -323,6 +323,9 @@ signals:
*/
QString OWNCLOUDSYNC_EXPORT extractErrorMessage(const QByteArray& errorResponse);
+/** Builds a error message based on the error and the reply body. */
+QString OWNCLOUDSYNC_EXPORT errorMessage(const QString& baseError, const QByteArray& body);
+
} // namespace OCC
#endif // NETWORKJOBS_H
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index 2bea9d5..e265578 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -566,14 +566,9 @@ void PropagateUploadFileQNAM::slotPutFinished()
"It is restored and your edit is in the conflict file."))) {
return;
}
- QString errorString = job->errorString();
-
QByteArray replyContent = job->reply()->readAll();
qDebug() << replyContent; // display the XML error in the debug
- QString extraMsg = extractErrorMessage(replyContent);
- if (!extraMsg.isEmpty()) {
- errorString += QLatin1String(" (") + extraMsg + QLatin1Char(')');
- }
+ QString errorString = errorMessage(job->errorString(), replyContent);
if (job->reply()->hasRawHeader("OC-ErrorString")) {
errorString = job->reply()->rawHeader("OC-ErrorString");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list