]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Wrap boost error message in ParameterHandler::parse_input_from_json 11976/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 29 Mar 2021 07:27:55 +0000 (09:27 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 29 Mar 2021 07:27:55 +0000 (09:27 +0200)
source/base/parameter_handler.cc

index fd93db41230c60c4a0e47f6bda6ce279d0a69014..d20928e43ca4d0c5da2bb5ac11819262e4033eb3 100644 (file)
@@ -761,7 +761,19 @@ ParameterHandler::parse_input_from_json(std::istream &in,
   boost::property_tree::ptree node_tree;
   // This boost function will raise an exception if this is not a valid JSON
   // file.
-  read_json(in, node_tree);
+  try
+    {
+      read_json(in, node_tree);
+    }
+  catch (const std::exception &e)
+    {
+      AssertThrow(
+        false,
+        ExcMessage(
+          "The provided JSON file is not valid. Boost aborted with the "
+          "following assert message: \n\n" +
+          std::string(e.what())));
+    }
 
   // The xml function is reused to read in the xml into the parameter file.
   // This means that only mangled files can be read.

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.