1
0
Fork 0

adapt to changes in sg_exception interface

sg_location now uses C strings. Also, change uses of sg_throwable to more
specific exceptions like sg_io_exception.
This commit is contained in:
Tim Moore 2009-06-16 10:41:17 +02:00
parent d30398f2b2
commit b588a92b7f
9 changed files with 21 additions and 15 deletions

View file

@ -261,9 +261,11 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
}
FGFontCache *fc = globals->get_fontcache();
HUD_Font = fc->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf"));
const char* fileName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
HUD_Font = fc->getTexFont(fileName);
if (!HUD_Font)
throw sg_throwable(string("/sim/hud/font/name is not a texture font"));
throw sg_io_exception("/sim/hud/font/name is not a texture font",
sg_location(fileName));
HUD_TextSize = fgGetFloat("/sim/hud/font/size", 10);

View file

@ -51,7 +51,7 @@ int main(int argc, char** argv)
readXML(argv[1], fdm);
} catch (const sg_exception &e) {
printf("XML parse error: %s (%s)\n",
e.getFormattedMessage().c_str(), e.getOrigin().c_str());
e.getFormattedMessage().c_str(), e.getOrigin());
}
Airplane* airplane = fdm.getAirplane();

View file

@ -85,7 +85,7 @@ int main(int argc, char** argv)
readXML(file, *fdm);
} catch (const sg_exception &e) {
printf("XML parse error: %s (%s)\n",
e.getFormattedMessage().c_str(), e.getOrigin().c_str());
e.getFormattedMessage().c_str(), e.getOrigin());
}
// ... and run

View file

@ -141,7 +141,7 @@ void guiErrorMessage (const char *txt, const sg_throwable &throwable)
string msg = txt;
msg += '\n';
msg += throwable.getFormattedMessage();
if (!throwable.getOrigin().empty()) {
if (!std::strlen(throwable.getOrigin()) != 0) {
msg += "\n (reported by ";
msg += throwable.getOrigin();
msg += ')';

View file

@ -512,8 +512,8 @@ FGInput::_init_joystick ()
<< "\"\nUsing default: \"" << source << '"');
} else {
throw sg_throwable(string("No joystick configuration file with "
"<name>default</name> entry found!"));
throw sg_exception(string("No joystick configuration file with <name>")
+ name + "</name> entry found!");
}
js_node = js_nodes->getChild("js", i, true);

View file

@ -127,11 +127,15 @@ HUD::~HUD()
void HUD::init()
{
const char* fontName = 0;
_font_cache = globals->get_fontcache();
if (!_font) {
fontName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
_font = _font_cache->getTexFont(fontName);
}
if (!_font)
_font = _font_cache->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf"));
if (!_font)
throw sg_throwable(string("/sim/hud/font/name is not a texture font"));
throw sg_io_exception("/sim/hud/font/name is not a texture font",
sg_location(fontName));
_font_size = fgGetFloat("/sim/hud/font/size", 8);
_font_renderer->setFont(_font);

View file

@ -70,9 +70,9 @@ FGInstrumentMgr::FGInstrumentMgr ()
readProperties( config.str(), config_props );
if ( !build() ) {
throw sg_throwable(string(
"Detected an internal inconsistency in the instrumentation\n"
"system specification file. See earlier errors for details."));
throw sg_error(
"Detected an internal inconsistency in the instrumentation\n"
"system specification file. See earlier errors for details.");
}
} catch (const sg_exception&) {
SG_LOG( SG_ALL, SG_ALERT, "Failed to load instrumentation system model: "

View file

@ -219,7 +219,7 @@ int main ( int argc, char **argv ) {
// logging, since logging may be
// disabled.
cerr << "Fatal error: " << t.getFormattedMessage() << endl;
if (!t.getOrigin().empty())
if (std::strlen(t.getOrigin()) != 0)
cerr << " (received from " << t.getOrigin() << ')' << endl;
} catch (const string &s) {

View file

@ -1279,7 +1279,7 @@ void fgInitFDM() {
} else if ( model == "yasim" ) {
cur_fdm_state = new YASim( dt );
} else {
throw sg_throwable(string("Unrecognized flight model '") + model
throw sg_exception(string("Unrecognized flight model '") + model
+ "', cannot init flight dynamics model.");
}
}