Howto:Add new fgcommands to FlightGear: Difference between revisions

Jump to navigation Jump to search
m
Line 137: Line 137:
== Exception handling ==
== Exception handling ==


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, which may terminate for one reason or another (such as missing files), 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. If you'd like to display error information using the native FlightGear GUI, you can use the "guiErrorMessage(const char*,sg_exception)" helper.
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)" helper.

Navigation menu