From c5c5a83ab200a99060a3595a464f84792e8a595e Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 16 Jul 2001 04:15:02 +0000 Subject: [PATCH] Use try/catch to flag FDM initialization errors. --- src/Main/fg_init.cxx | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 1550b111b..5f72d1930 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -509,24 +509,30 @@ bool fgInitSubsystems( void ) { aircraft_dir = fgGetString("/sim/aircraft-dir"); const string &model = fgGetString("/sim/flight-model"); - if (model == "larcsim") { - cur_fdm_state = new FGLaRCsim( dt ); - } else if (model == "jsb") { - cur_fdm_state = new FGJSBsim( dt ); - } else if (model == "ada") { - cur_fdm_state = new FGADA( dt ); - } else if (model == "balloon") { - cur_fdm_state = new FGBalloonSim( dt ); - } else if (model == "magic") { - cur_fdm_state = new FGMagicCarpet( dt ); - } else if (model == "external") { - cur_fdm_state = new FGExternal( dt ); - } else { - SG_LOG(SG_GENERAL, SG_ALERT, - "Unrecognized flight model '" << model - << ", can't init aircraft"); + try { + if (model == "larcsim") { + cur_fdm_state = new FGLaRCsim( dt ); + } else if (model == "jsb") { + cur_fdm_state = new FGJSBsim( dt ); + } else if (model == "ada") { + cur_fdm_state = new FGADA( dt ); + } else if (model == "balloon") { + cur_fdm_state = new FGBalloonSim( dt ); + } else if (model == "magic") { + cur_fdm_state = new FGMagicCarpet( dt ); + } else if (model == "external") { + cur_fdm_state = new FGExternal( dt ); + } else { + SG_LOG(SG_GENERAL, SG_ALERT, + "Unrecognized flight model '" << model + << ", can't init aircraft"); + exit(-1); + } + } catch ( ... ) { + SG_LOG(SG_GENERAL, SG_ALERT, "FlightGear aborting\n\n"); exit(-1); } + cur_fdm_state->init(); cur_fdm_state->bind();