Hi,

recently one of my aircraft had invalid XML, and the parser duly threw
an exception. Unfortunately, fgInitFDM() considered it appropriate to
report the error as

   ,----
   | FlightGear aborting
   `----

and actually aborting FlightGear instead of at least printing something
potentially helpful like

   ,----
   | Error reading default aircraft: not well-formed
   |  at /path/to/data/Aircraft/AN-225/AN-225-set.xml,
   | line 11, column 1
   `----

Obviously, fgInitFDM()'s hiding the exception did not quite help in
solving the problem.

May I suggest  fixing void fgInitFDM(void) in src/Main/fg_init.cxx in a
way similar to the one in my following quick fix?

Probably the "Unrecognized flight model" case should also use abort()
instead of exit() (or just throw its own proper UnknownFDM exception),
and if one really needs to SG_LOG some message on exceptions, I'd expect
that logging something information about the actual exception would be a
good idea.


Index: src/Main/fg_init.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_init.cxx,v
retrieving revision 1.172.2.8
diff -u -p -r1.172.2.8 fg_init.cxx
--- src/Main/fg_init.cxx        1 May 2007 18:06:46 -0000       1.172.2.8
+++ src/Main/fg_init.cxx        20 May 2007 17:03:40 -0000
@@ -1328,7 +1328,9 @@ void fgInitFDM() {
     double dt = 1.0 / fgGetInt("/sim/model-hz");
     string model = fgGetString("/sim/flight-model");

+    /* Avoid uselessly hiding exceptions.
     try {
+    */
         if ( model == "larcsim" ) {
             cur_fdm_state = new FGLaRCsim( dt );
         } else if ( model == "jsb" ) {
@@ -1409,10 +1411,12 @@ void fgInitFDM() {
                    << "', cannot init flight dynamics model.");
             exit(-1);
         }
+/* Avoid swallowing exceptions without any good reason.
     } catch ( ... ) {
         SG_LOG(SG_GENERAL, SG_ALERT, "FlightGear aborting\n\n");
         exit(-1);
     }
+  And this should probably have used abort(3) (instead of exit(3))
anyway. */
 }

 static void printMat(const sgVec4 *mat, char *name="")


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to