20,741
edits
Line 139: | Line 139: | ||
To be on the safe side, complex fgcommands should make use of exception handling to catch exceptions and deal with them gracefully, so that they cannot affect the simulator critically. | To be on the safe side, complex fgcommands should make use of exception handling to catch exceptions and deal with them gracefully, so that they cannot affect the simulator critically. | ||
This is accomplished by using standard C++ try/catch blocks, usually catching an sg_exception. The SG_LOG() macro can be used to print debugging information to the console. | This is accomplished by using standard C++ try/catch blocks, usually catching an sg_exception. The SG_LOG() macro can be used to print debugging information to the console. If you'd like to display error information using the native FlightGear GUI, you can use the "guiErrorMessage(const char*,sg_exception)". | ||
For example, see the callback function "do_preferences_load" in [http://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_commands.cxx#line445 line 445]: | For example, see the callback function "do_preferences_load" in [http://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_commands.cxx#line445 line 445]: |