refactoring: make assert more informative 31/200731/3
authorAdrian Szyndela <adrian.s@samsung.com>
Fri, 1 Mar 2019 12:14:25 +0000 (13:14 +0100)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 7 Mar 2019 07:37:43 +0000 (07:37 +0000)
Function parseAssert() showed only that an error occurred.
A macro instead shows also the error condition and line number.

Change-Id: Ibd686286c58b657fd578f92bd4328072aa892933

src/internal/xml_parser.cpp

index c3bc869..d5815e5 100644 (file)
@@ -42,11 +42,12 @@ public:
        bool ignore_always{false};
 };
 
-void parseAssert(bool condition) {
-       assert(condition);
-       if (!condition) {
-               throw std::runtime_error("Parsing error");
-       }
+#define parseAssert(cond) \
+{ \
+       assert(cond); \
+       if (!(cond)) { \
+               throw std::runtime_error("Parsing error"); \
+       } \
 }
 
 void start_element_handler(void *data, const char *el, const char **attr) {