In case of an error occurring in an operation of an Active Expert object (user-defined or environmental), an exception is raised. The programmer has two possibilities to handle errors:
Err
object. This approach is more natural for Visual Basic programmers, but it restricts the amount of information passed back on error to the Description
property of the Err
object.
The Visual Basic error handling model allows programmers to perform special actions when an error occurs, such as jumping to a particular line of code. When an exception occurs in the Active Expert, the standard Visual Basic error handling works as expected. However, the set of Visual Basic error exceptions that are returned is limited.
The Active Expert provides additional information about the exception through the There are two major categories of exceptions:
Visual Basic Error Handling Model
Description
property of the Visual Basic built-in Err
object. When a TUXEDO related error occurs, the description string is set to indicate the type of error. When an application-specific error happens, the description string is set to "Application error".
Active Expert Style Exception Handling
A user exception will be raised when an application error occurs (TPESVCFAIL) in the TUXEDO service. The name of the exception is always <operation name> A field of type long will be implicitly added to the body of the exception, to hold the value of the Exception
. The body of the exception consists of the [out] and [inout] parameters of the operation which are marked [exception] or [both] in the Contract Repository. Setting the Return Exception
field of the operation to FALSE in the Contract Repository will cause no data to be returned.
tpurcode
passed back by the service.
Listing 4-21
Definition for a User Exception Indicating an Application Error
module Banking
{
interface Account
{
long Withdrawal (in long AccountID, in double Sum, out double Balance)
}
exception WithdrawalException(double Balance, long tpurcode)
}
Exceptions defined in the CosTransactions
module are also passed back as user exceptions.
If a TUXEDO system error occurs during a method call to a method of an OLE Automation View object, the Active Expert raises a system exception. System exceptions raised by operations of environmental objects are documented with the descriptions of the operations.
Each operation of objects in the Active Expert has an additional optional return parameter of type Variant. When the programmer passes a Variant variable to fill, no Visual Basic exception is triggered. Instead, the return parameter returns the exception information in the format of an OLE Automation object.
If an exception occurs, the return parameter contains an object to get the data from the exception. This object is similar to a structure pseudo-object, with properties for each value and the method INSTANCE_Clone
. For instance, in the above example the exception passed back for the Withdrawal()
operation would have properties Balance
and tpurcode
. To determine the type of exception, use the property EX_majorCode
. EX_majorCode
has three possible values:
In addition, for system exceptions the property The code in the next "Example" section demonstrates both styles of error handling.
EX_minorCode
of type long is defined. In the Active Expert, this property is used to pass back the tperrcode
upon TUXEDO error. Description text of the TUXEDO error can be retrieved by passing the EX_minorCode
to the get_error_text()
operation of Session
.