Appendix A. Error Handling

Table of Contents

Inventor provides a basic error handling mechanism for use with both the optimized and debugging versions of Inventor. As shown in Figure A.1, “ SoError Class Tree, three classes are derived from the base class, SoError. Read errors occur during reading of an Inventor file. Memory errors occur when an application runs out of memory. Debugging errors occur as the result of a programming error. Most debugging errors are generated only in the debugging version of Inventor and are not checked in the optimized version. A correct application does not generate any debugging errors. In the beginning, it's a good idea to link with the debugging version of Inventor to ensure that your program is correct. Later, when no errors are generated, you can switch to the optimized version.

SoError Class Tree

Figure A.1.  SoError Class Tree

For example, suppose Inventor encounters an unrecognized field name when it is reading a file. The following steps occur:

  1. Inventor calls the static SoReadError::post() method and passes in the correct arguments.

  2. The SoReadError( C++ | Java | .NET ) class creates an instance of itself. Within this instance, it stores the debug string, a character string that represents a detailed error message. (Use getDebugString() to obtain the debug string.)

  3. The SoReadError( C++ | Java | .NET ) class passes the error instance to its error handler. The default error handler for all error classes simply prints the debug string to stderr. You can register your own error handler for specialized behavior. For example, in this case, you might want to bring up a window displaying a message saying that an error occurred during reading. Use the setHandlerCallback() method to register your own handler for an error class.