signal statement to signal an error during procedure execution. Such an error is essentially the same as an error signaled by G2 itself. The only difference is that the signal statement, rather than G2, supplies the error object. The syntax of the
signal statement is:
signal error-object;
| Element... | Meaning... |
|---|---|
error-object
|
An instance of the class error or of any subclass of error.
|
signal statement executes, G2 looks for a block error handler whose class matches that of the error-object specified in the statement. If G2 finds such a handler, it invokes the handler, passing it error-object. If G2 does not find a block error handler, it invokes the default error handler on error-object.Thus the
signal statement, rather than G2, defines the type of a signalled error. This feature, in conjunction with the ability to define error classes using multiple inheritance, allows very complex handling of signaled errors.The examples in this section assume that you have read Handling Errors in a Procedure, and do not reiterate the detailed descriptions of error handling that appear in that section.
Signaling the Default Error Handler
The following procedures are demonstrate-default-error-handler, the same procedure that appeared in Default Handler Example, and sigproc, the procedure that was undefined in that example. The procedure sigproc contains an example of a signal statement:
![]() |
![]() |
The
signal statement in the example specifies an error object of class zerodivide, a subclass of error. Calling demonstrate-default-error-handler calls sigproc with an argument of 0, invoking sigproc's signal statement on an error object of class zerodivide.zdev to the default error handler. The system-defined default error handler posts the following to the Operator Logbook:
![]() |
The system-defined default error handler has added additional information to the error-description of
zdev. G2 provides such information as a convenience whenever a signaled error reaches the default error handler. Signalling a Block Error Handler
The following procedures are demonstrate-block-error-handler, the same procedure that appeared in Block Error Handler Example, and sigproc, the procedure that was undefined in that example.
![]() |
![]() |
Calling
demonstrate-default-error-handler calls sigproc with an argument of 0, invoking sigproc's signal statement on zdev. G2 passes zdev to the block error handler of the calling block, which posts the following to the Message Board (not the logbook):
![]() |