Scripting the Error event
What you do
To handle errors in the Error event of the Connection object,
you create a user object that customizes the definition of the object.
Once you have created the custom Connection object, you can refer
to it anywhere in your scripts where you use a Connection object. If you
use the JaguarORB event, you can script its Error event in the same
way.
The Connection Object wizard creates a custom Connection object
for you. See “Using the wizard
to create a Connection object”.
Arguments to the Error event
The Error event of the custom Connection object has several
arguments that provide information about the condition that caused
the error. For example, these arguments provide the error number
and error text, as well as the name of the object that caused the
error and the full text of the script where the error occurred.
In addition to the arguments that provide error information,
the Error event has an argument that lets you specify what action
to take. To specify the action, you assign one of four enumerated
values (ExceptionFail!, ExceptionRetry!, ExceptionIgnore!,
or ExceptionSubstituteReturnValue!) to the
Action argument of the Error event.
Example
In this example, the Error event script informs the user of
the condition that caused the communications error and gives the
user the opportunity to control what happens next. Depending on
the user’s input, the client application fails, retries
the operation, or ignores the error and continues processing:
1 |
int li_choice<br>li_choice = MessageBox("Connection error " + &<br> string(ErrorNumber), ErrorText, &<br> Question!,AbortRetryIgnore!) |
1 |
CHOOSE CASE li_choice<br> CASE 1<br> Action = ExceptionFail!<br> CASE 2<br> Action = ExceptionRetry!<br> CASE 3<br> Action = ExceptionIgnore!<br>END CHOOSE |