In any application, error situations will inevitably arise. When an error occurs, HOOPS Visualize uses the ::Report_Error function to report warning, error, and informational messages back to the application.
The ::Report_Error function attempts to display errors, warnings and information messages to the user. Although ::Report_Error is normally called by the system, you can determine what types of message you would like to receive via ::Define_System_Options.
The system options has settings for fatal errors, errors, warnings and informational messages. You can enable or disable each category as a whole. In the following code snippet, we disable all warnings and errors:
You can also specifically allow some messages as well as have other messages reported only once. To enable/disable a particular message, please indicate its category and specific number when calling ::Define_System_Options. A list of error codes can be found in hpserror.h. In the code sample below, we disable all errors except the error 1/3, which indicates the error with category 1 and specific number three. The error 21/9 will only be reported once.
Note that the basic on/off setting overrides all previous settings. In the above case, if the off setting were placed at the end, all errors would be turned off.
Once an error is reported and displayed, HOOPS usually returns control back to the application.
However, when some errors arises, they tend to lead to a cascade of errors. Thus, it might be sometime before your application can retain control again. To mitigate an error cascade, you can set a message limit via ::Define_System_Options. This message limit is monitored in ::Report_Error. When the limit is met, HOOPS will return control to the application. The message counter in ::Report_Error is reset whenever ::Define_System_Options is called again with another message limit setting.
When HOOPS starts up, ::Report_Error is defined as the default error handler. ::Report_Error displays error and warnings. You can, however, define your own error handlers to process and respond to errors, warnings and information coming from HOOPS. To do this simply, create a function which takes the same parameters as defined in ::Report_Error. This includes the category, specific number, severity, message and call stack. Then register your handler with HOOPS using the ::Define_Error_Handler function as shown in the code sample below:
If you want to let ::Report_Error handle most errors while your error handler responds to some key errors, you can unregister ::Report_Error via ::UnDefine_Error_Handler. Then, call ::Report_Error directly in your function. The following code sample shows how to perform a search for a specific registered error handler and then unregister it: