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.
This commit is contained in:
Christian Kamm 2015-06-04 09:44:11 +02:00
Родитель e04882cc7c
Коммит 2ed329e025
5 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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();

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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");