Shadowing the Default Error Handler
You can shadow the system-defined default error handler with a user-defined default error handler. Such a handler is a procedure that takes one argument: an error object.
Shadowing the system-defined handler with a user-defined handler allows you to specify the handling of any or all errors, including those that originate outside the context of a procedure, such as rule, formula, and simulator errors.
The G2 Simulator is a superseded capability. For more information, see Appendix F, Superseded Practices.
When a user-defined default error handler exists, G2 invokes it for any error whose type matches the class of the handler's argument. G2 then invokes the system-defined default error handler only for:
A user-defined default error handler can be a method declaration. When G2 invokes such a handler, it looks for a method defined for the class of the error object, and invokes it if it exists. If no such method exists, G2 invokes the system-defined default error handler.
Note: More sophisticated techniques for managing error messages are available through GFR. See the G2 Foundation Resources User's Guide for details.
Creating a User-Defined Default Error Handler
Any procedure (including a method) that takes one argument of class error, or of any subclass of error, can be a user-defined default error handler. The procedure need have no other special properties.
To put a user-defined default error handler into effect, you must register the handler. G2 provides system procedures to register and deregister default error handlers, and to obtain the name of the handler currently in effect.
Resetting G2 does not affect handler shadowing: any registered handler remains in effect when G2 restarts.
To register a default error handler:
To deregister a default error handler:
To get the default error handler:
Each of these procedures is described in more detail in the G2 System Procedures Reference Manual.
Caution: When you shadow the default error handler, be sure that the user-defined handler manages transient error objects correctly, or a memory leak will result. For details see Error Object Memory Management.
Copyright © 1997 Gensym Corporation, Inc.