// $Id$
#include <simgear/compiler.h>
+#include <simgear/misc/exception.hxx>
#ifdef HAVE_CONFIG_H
# include <config.h>
SGPropertyNode root;
-
- if (!readProperties(input, &root)) {
- SG_LOG(SG_INPUT, SG_ALERT, "Malformed property list for hud.");
- return 0;
+ try {
+ readProperties(input, &root);
+ } catch (const sg_io_exception &e) {
+ string message = "Error reading HUD: ";
+ message += e.getMessage();
+ message += "\n at ";
+ message += e.getLocation().asString();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ mkDialog(message.c_str());
+ return 0;
}
SGPropertyNode root2;
- if (readProperties(path.str(), &root2)) {
-
- readInstrument(&root2);
-
- }//if
+ try {
+ readProperties(path.str(), &root2);
+ } catch (const sg_io_exception &e) {
+ string message = "Error reading HUD instrument: ";
+ message += e.getMessage();
+ message += "\n at ";
+ message += e.getLocation().asString();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ mkDialog(message.c_str());
+ continue;
+ }
+ readInstrument(&root2);
}//for loop(i)
return 0;
#endif
#include <simgear/compiler.h>
+#include <simgear/misc/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/debug/logstream.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
+#include <GUI/gui.h>
+
#include "panel.hxx"
#include "steam.hxx"
#include "panel_io.hxx"
{
SGPropertyNode root;
- if (!readProperties(input, &root)) {
- SG_LOG( SG_COCKPIT, SG_ALERT, "Malformed property list for panel." );
+ try {
+ readProperties(input, &root);
+ } catch (const sg_io_exception &e) {
+ string message = e.getMessage();
+ message += "\n at ";
+ message += e.getLocation().asString();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ mkDialog(message.c_str());
return 0;
}
return readPanel(&root);
path.append(relative_path);
SGPropertyNode root;
- if (!readProperties(path.str(), &root)) {
- SG_LOG( SG_COCKPIT, SG_ALERT, "Malformed property list for panel." );
+ try {
+ readProperties(path.str(), &root);
+ } catch (const sg_io_exception &e) {
+ string message = e.getMessage();
+ message += "\n at ";
+ message += e.getLocation().asString();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ mkDialog(message.c_str());
return 0;
}
return readPanel(&root);
// fg_commands.cxx - internal FGFS commands.
#include <simgear/compiler.h>
+#include <simgear/misc/exception.hxx>
#include STL_STRING
#include STL_FSTREAM
props_path.append(path);
SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences from "
<< props_path.str());
- if (!readProperties(props_path.str(), globals->get_props())) {
- SG_LOG(SG_INPUT, SG_ALERT, "Failed to reread 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);
+ mkDialog(message.c_str());
return false;
- } else {
- SG_LOG(SG_INPUT, SG_INFO, "Successfully read global preferences.");
- return true;
}
+ SG_LOG(SG_INPUT, SG_INFO, "Successfully read global preferences.");
+ return true;
}
# include <simgear/compiler.h>
#endif
+#include <simgear/misc/exception.hxx>
+
#include STL_IOSTREAM
#include <Autopilot/newauto.hxx>
#endif
#include <Objects/matlib.hxx>
+#include <GUI/gui.h>
+
#include "fgfs.hxx"
#include "fg_props.hxx"
bool
fgSaveFlight (ostream &output)
{
- return writeProperties(output, globals->get_props());
+ try {
+ writeProperties(output, globals->get_props());
+ } catch (const sg_io_exception &e) {
+ string message = "Error saving flight: ";
+ message += e.getMessage();
+ message += "\n at ";
+ message += e.getLocation().asString();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ mkDialog(message.c_str());
+ return false;
+ }
+ return true;
}
fgLoadFlight (istream &input)
{
SGPropertyNode props;
- if (readProperties(input, &props)) {
- copyProperties(&props, globals->get_props());
- // When loading a flight, make it the
- // new initial state.
- globals->saveInitialState();
- } else {
- SG_LOG(SG_INPUT, SG_ALERT, "Error restoring flight; aborted");
+ try {
+ readProperties(input, &props);
+ } catch (const sg_io_exception &e) {
+ string message = "Error reading saved flight: ";
+ message += e.getMessage();
+ message += "\n at ";
+ message += e.getLocation().asString();
+ SG_LOG(SG_INPUT, SG_ALERT, message);
+ mkDialog(message.c_str());
return false;
}
-
+ copyProperties(&props, globals->get_props());
+ // When loading a flight, make it the
+ // new initial state.
+ globals->saveInitialState();
return true;
}