]> git.mxchange.org Git - flightgear.git/commitdiff
- catch exception from readProperties and exit
authorcurt <curt>
Thu, 19 Jul 2001 04:53:13 +0000 (04:53 +0000)
committercurt <curt>
Thu, 19 Jul 2001 04:53:13 +0000 (04:53 +0000)
src/Main/fg_init.cxx
src/Main/options.cxx

index 699765c32d3dabf6a282d014514260b63121dfa1..e69190122c481476acc28229186fa6d985979ba9 100644 (file)
@@ -52,6 +52,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/misc/exception.hxx>
 
 #include STL_STRING
 
@@ -215,12 +216,17 @@ bool fgInitConfig ( int argc, char **argv ) {
     SGPath props_path(globals->get_fg_root());
     props_path.append("preferences.xml");
     SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
-    if (!readProperties(props_path.str(), globals->get_props())) {
-      SG_LOG(SG_INPUT, SG_ALERT, "Failed to read global preferences from "
-            << props_path.str());
-    } else {
-      SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
+    try {
+      readProperties(props_path.str(), globals->get_props());
+    } catch (const sg_io_exception &e) {
+      string message = "Error reading global preferences: ";
+      message += e.getMessage();
+      message += "\n at ";
+      message += e.getLocation().asString();
+      SG_LOG(SG_INPUT, SG_ALERT, message);
+      exit(2);
     }
+    SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
 
     // Attempt to locate and parse the various config files in order
     // from least precidence to greatest precidence
index 93fff76a3692489e65ebfa0721933f0004819b43..9e77dd783d49438607327b6135718d775e7a3ff7 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/misc/exception.hxx>
 
 /* normans fix */
 #if defined(FX) && defined(XMESA)
@@ -50,6 +51,8 @@ bool global_fullscreen = true;
 #  include <NetworkOLK/network.h>
 #endif
 
+#include <GUI/gui.h>
+
 #include "globals.hxx"
 #include "fg_init.hxx"
 #include "fg_props.hxx"
@@ -877,10 +880,15 @@ parse_option (const string& arg)
        parse_flightplan ( arg.substr (14) );
     } else if ( arg.find( "--config=" ) == 0 ) {
         string file = arg.substr(9);
-        if (!readProperties(file, globals->get_props())) {
-         SG_LOG(SG_IO, SG_ALERT,
-                "--config: failed to read properties from " << file);
-         return FG_OPTIONS_ERROR;
+       try {
+         readProperties(file, globals->get_props());
+       } catch (const sg_io_exception &e) {
+         string message = "Error loading config file: ";
+         message += e.getMessage();
+         message += "\n at ";
+         message += e.getLocation().asString();
+         SG_LOG(SG_INPUT, SG_ALERT, message);
+         exit(2);
        }
     } else {
        SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );