XML: print specified error cases while parsing
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 11 Nov 2015 11:09:45 +0000 (20:09 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 13 Nov 2015 07:39:42 +0000 (16:39 +0900)
- UnexpectedElementError
- NotWellFormedError
- PrematureEndOfDocumentError

Change-Id: Iaf80dfb40cc0167636fa190172991ef10a4f8f9a
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/qt5_supplement.cpp
tizen/src/ui/xmllayoutparser.cpp
tizen/src/ui/xmllayoutparser.h

index 2b33ba515cec348ae70bcbcf708a81e66f67c8cf..ed39643b2497934ec47ff193bd38e1682a2273c4 100644 (file)
@@ -453,13 +453,18 @@ void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QSt
         fprintf(stderr, "%s|%5d|S|%10.10s|%4u|%s\n", dateMsg.constData(),
                 qemu_get_thread_id(), fname.trimmed().constData(), context.line,
                 localMsg.trimmed().constData());
+        {
+            QString err;
+            QMessageBox::critical(0, EMULATOR_TITLE,
+                                  QString(MSG_INTERNAL_ERR) +
+                                  err.sprintf("%s", (localMsg.trimmed()).constData()) +
+                                  MSG_EMULATOR_EXIT);
+        }
 
-        QString err;
-        QMessageBox::critical(0, EMULATOR_TITLE,
-                              QString(MSG_INTERNAL_ERR) +
-                              err.sprintf("%s", (localMsg.trimmed()).constData()) +
-                              MSG_EMULATOR_EXIT);
         abort();
+    default:
+        qFatal("invalid message type");
+        break;
     }
 }
 
index a7c841909e03866cf2c4d504379a98a947b40487..2b016ecacb6fcd9023a42eaeb392396254b41730 100644 (file)
@@ -555,6 +555,10 @@ QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml)
         }
     }
 
+    if (xml.hasError() == true) {
+        printError(xml.error());
+    }
+
     return layoutVersion;
 }
 
@@ -652,6 +656,10 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
         }
     }
 
+    if (xml.hasError() == true) {
+        printError(xml.error());
+    }
+
     return layoutVersion;
 }
 
@@ -679,3 +687,27 @@ void XmlLayoutParser::makeGeneralCon(ControllerForm *form)
     form->setCenteralRect(painter.getCenteralRect());
     form->setGeneralPurpose(true);
 }
+
+void XmlLayoutParser::printError(QXmlStreamReader::Error err)
+{
+    switch (err) {
+    case QXmlStreamReader::NoError:
+        /* do nothing */
+        break;
+    case QXmlStreamReader::UnexpectedElementError:
+        qCritical("The parser encountered an element that was different to those it expected.");
+        break;
+    case QXmlStreamReader::CustomError:
+        qCritical("A custom error has been raised with raiseError()");
+        break;
+    case QXmlStreamReader::NotWellFormedError:
+        qCritical("The parser internally raised an error due to the read XML not being well-formed.");
+        break;
+    case QXmlStreamReader::PrematureEndOfDocumentError:
+        qCritical("The input stream ended before a well-formed XML document was parsed.");
+        break;
+    default:
+        qFatal("invalid error type");
+        break;
+    }
+}
index de643d10cdd853d9165f2e84a5c63b3484d2805d..1a8840a755820d267aaa8218f6369c37466f085d 100644 (file)
@@ -70,6 +70,8 @@ private:
     ControllerForm *parseControllerForm(QXmlStreamReader &xml);
     void makeGeneralCon(ControllerForm *form);
 
+    void printError(QXmlStreamReader::Error err);
+
     QString xmlPath;
     UiInformation *uiInfo;
 };