1
0
Fork 0

- catch exception from readProperties and exit

This commit is contained in:
curt 2001-07-19 04:53:13 +00:00
parent 7004475732
commit 5abff48c8a
2 changed files with 23 additions and 9 deletions

View 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

View 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 << "'" );