Network errors: Use exception name, if message is empty #2718
authorChristian Kamm <mail@ckamm.de>
Fri, 2 Oct 2015 13:25:34 +0000 (15:25 +0200)
committerChristian Kamm <mail@ckamm.de>
Fri, 2 Oct 2015 13:25:34 +0000 (15:25 +0200)
src/libsync/abstractnetworkjob.cpp

index ed675cdc9a21c484fe73e2463b2285eb7921f25b..599e5be9a9ee8cbd0a95501485c2a2bde338ae25 100644 (file)
@@ -263,13 +263,21 @@ QString extractErrorMessage(const QByteArray& errorResponse)
         return QString::null;
     }
 
+    QString exception;
     while (!reader.atEnd() && reader.error() == QXmlStreamReader::NoError) {
         reader.readNextStartElement();
         if (reader.name() == QLatin1String("message")) {
-            return reader.readElementText();
+            QString message = reader.readElementText();
+            if (!message.isEmpty()) {
+                return message;
+            }
+        } else if (reader.name() == QLatin1String("exception")) {
+            exception = reader.readElementText();
         }
+
     }
-    return QString::null;
+    // Fallback, if message could not be found
+    return exception;
 }
 
 QString errorMessage(const QString& baseError, const QByteArray& body)