mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +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 AbstractNetworkJob::errorStringParsingBody(QByteArray *body)
|
||||||
{
|
{
|
||||||
QString base = errorString();
|
const auto base = errorString();
|
||||||
if (base.isEmpty() || !reply()) {
|
if (base.isEmpty() || !reply()) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray replyBody = reply()->readAll();
|
const auto replyBody = reply()->readAll();
|
||||||
if (body) {
|
if (body) {
|
||||||
*body = replyBody;
|
*body = replyBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString extra = extractErrorMessage(replyBody);
|
const auto extra = extractErrorMessage(replyBody);
|
||||||
// Don't append the XML error message to a OC-ErrorString message.
|
// Don't append the XML error message to a OC-ErrorString message.
|
||||||
if (!extra.isEmpty() && !reply()->hasRawHeader("OC-ErrorString")) {
|
if (!extra.isEmpty() && !reply()->hasRawHeader("OC-ErrorString")) {
|
||||||
return QString::fromLatin1("%1 (%2)").arg(base, extra);
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
|
@ -416,7 +416,7 @@ QString extractErrorMessage(const QByteArray &errorResponse)
|
||||||
while (!reader.atEnd() && !reader.hasError()) {
|
while (!reader.atEnd() && !reader.hasError()) {
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.name() == QLatin1String("message")) {
|
if (reader.name() == QLatin1String("message")) {
|
||||||
QString message = reader.readElementText();
|
const auto message = reader.readElementText();
|
||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue