]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#10,!3] Generator updated
authorTomek Mrugalski <tomasz@isc.org>
Thu, 4 Oct 2018 20:54:33 +0000 (22:54 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 29 Oct 2019 17:57:13 +0000 (18:57 +0100)
doc/docgen/kea_docgen.cc

index 28b2ebb52dcf403b8233cf12566b2f818c771a74..bd22cb6641e9e3dc4573950c41e995010587343f 100644 (file)
@@ -38,6 +38,8 @@ public:
 
         int cnt = 0;
 
+        int errors = 0; // number of errors encountered
+
         try {
             for (auto f : files) {
                 string cmd = f;
@@ -52,14 +54,24 @@ public:
                     continue;
                 }
 
-                cout << "Loading description of command " << cmd << "... ";
-                ElementPtr x = Element::fromJSONFile(f, false);
-                cout << "loaded, sanity check...";
+                try {
+                    cout << "Loading description of command " << cmd << "... ";
+                    ElementPtr x = Element::fromJSONFile(f, false);
+                    cout << "loaded, sanity check...";
+
+                    sanityCheck(f, x);
 
-                sanityCheck(f, x);
+                    cmds_.insert(make_pair(cmd, x));
+                    cout << " looks ok." << endl;
 
-                cmds_.insert(make_pair(cmd, x));
-                cout << " looks ok." << endl;
+                } catch (const exception& e) {
+                    cout << "ERROR: " << e.what() << endl;
+                    errors++;
+                }
+
+                if (errors) {
+                    continue;
+                }
 
                 cnt++;
             }
@@ -69,7 +81,10 @@ public:
         }
 
         cout << "Loaded " << cmds_.size() << " commands out of " << files.size()
-             << " file(s)" << endl;
+             << " file(s), " << errors << " error(s) detected." << endl;
+        if (errors) {
+            isc_throw(Unexpected, errors << " error(s) detected while loading JSON files");
+        }
     }
 
     /// @brief checks if mandatory string parameter is specified
@@ -412,7 +427,7 @@ public:
               << "}</screen>" << endl;
         }
         if (cmd->contains("cmd-comment")) {
-            f << cmd->get("cmd-comment")->stringValue();
+            f << escapeString(cmd->get("cmd-comment")->stringValue());
         }
         f << "</para>" << endl << endl;