Global Exception Handlers

Exception handlers can be designed and armed as global exception handlers; that is, once armed, they stay active until they are disarmed or until the application terminates. Global exception handlers are useful for handling lock exceptions, connection exceptions, and as 'if all else fails' handlers for unexpected application and system exceptions such as String Too Long errors.

The following is an example of arming a global exception handler.

on ConnectionException do app.connectionExceptionHandler(exception) global;

To disarm a previously‑armed global exception handler, write:

on ConnectionException do null global;

Typically, if you need a global exception handler, it is convenient to arm it in the application's initialize method or startup form load event. However, you need to be careful that the receiver of the handler doesn't get subsequently deleted. For example, if a global exception handler is armed on a form (with the form as receiver) and that form is subsequently closed and deleted, you will have a handler in the exception handler stack with an invalid receiver object.

As an example, you could always code your global exception handlers as methods of the Application subclass, although you could equally well use other classes such as your subclass of Global or of Process.