1
0
Fork 0

Let exceptions fall through to main, and use cerr to report them (in

case logging is disabled).  This way, when people specify a
non-existant aircraft or have an error in a custom XML file, they'll
get an error report, at least.
This commit is contained in:
david 2002-04-04 17:51:40 +00:00
parent 8ac5a5327e
commit f450e6d9d1
3 changed files with 12 additions and 19 deletions

View file

@ -231,14 +231,7 @@ 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");
try {
readProperties(props_path.str(), globals->get_props());
} catch (const sg_exception &e) {
string message = "Error reading global preferences: ";
message += e.getFormattedMessage();
SG_LOG(SG_INPUT, SG_ALERT, message);
exit(2);
}
SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
// Read the default aircraft config file.

View file

@ -31,6 +31,11 @@
#endif
#include <simgear/compiler.h>
#include <iostream>
SG_USING_STD(cerr);
SG_USING_STD(endl);
#include <simgear/misc/exception.hxx>
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/route/route.hxx>
@ -1598,9 +1603,11 @@ int main ( int argc, char **argv ) {
try {
mainLoop(argc, argv);
} catch (sg_throwable &t) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Fatal error: " << t.getFormattedMessage()
<< "\n (received from " << t.getOrigin() << ')');
// We must use cerr rather than
// logging, since logging may be
// disabled.
cerr << "Fatal error: " << t.getFormattedMessage()
<< "\n (received from " << t.getOrigin() << ')' << endl;
exit(1);
}

View file

@ -942,14 +942,7 @@ parse_option (const string& arg)
apath.concat( "-set.xml" );
SG_LOG(SG_INPUT, SG_INFO, "Reading aircraft: " << arg.substr(11)
<< " from " << apath.str());
try {
readProperties( apath.str(), globals->get_props() );
} catch (const sg_exception &e) {
string message = "Error loading aircraft file: ";
message += e.getFormattedMessage();
SG_LOG(SG_INPUT, SG_ALERT, message);
exit(2);
}
} else {
SG_LOG( SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'" );
return FG_OPTIONS_ERROR;