mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Modernize extractErrorMessage and AbstractNetworkJob::errorStringParsingBody.
- Add const auto. - Remove extra error message information to make it more user friendly. Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
parent
6d50b87587
commit
b3b48dc163
1 changed files with 5 additions and 5 deletions
|
@ -323,20 +323,20 @@ QString AbstractNetworkJob::errorString() const
|
|||
|
||||
QString AbstractNetworkJob::errorStringParsingBody(QByteArray *body)
|
||||
{
|
||||
QString base = errorString();
|
||||
const auto base = errorString();
|
||||
if (base.isEmpty() || !reply()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
QByteArray replyBody = reply()->readAll();
|
||||
const auto replyBody = reply()->readAll();
|
||||
if (body) {
|
||||
*body = replyBody;
|
||||
}
|
||||
|
||||
QString extra = extractErrorMessage(replyBody);
|
||||
const auto extra = extractErrorMessage(replyBody);
|
||||
// Don't append the XML error message to a OC-ErrorString message.
|
||||
if (!extra.isEmpty() && !reply()->hasRawHeader("OC-ErrorString")) {
|
||||
return QString::fromLatin1("%1 (%2)").arg(base, extra);
|
||||
return extra;
|
||||
}
|
||||
|
||||
return base;
|
||||
|
@ -416,7 +416,7 @@ QString extractErrorMessage(const QByteArray &errorResponse)
|
|||
while (!reader.atEnd() && !reader.hasError()) {
|
||||
reader.readNextStartElement();
|
||||
if (reader.name() == QLatin1String("message")) {
|
||||
QString message = reader.readElementText();
|
||||
const auto message = reader.readElementText();
|
||||
if (!message.isEmpty()) {
|
||||
return message;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue