The TivExceptionsApp includes three classes that assist in generating a Tivoli Application System Error event when a Smalltalk exception occurs.
The TivSampleExceptionsCheckingAccount class methods define two exceptions that are represented as class variables. One of the exceptions, TivExCheckingAccountOverdrawn, is defined by
anExceptionalEvent := TivExceptionalEventRoot root newChild. anExceptionalEvent description: 'Checking Account Overdrawn'. anExceptionalEvent resumable: false. anExceptionalEvent defaultHandler: [:sig | System errorMessage sig description. sig exitWith: 'done']. self TivExCheckingAccountOverdrawn: anExceptionalEvent.
The following TivSampleExceptionsCheckingAccount instance method illustrates how the TivExCheckingAccountOverdrawn exception is signalled:
withdraw: anAmount self balance >= anAmount ifTrue: [self balance: self balance - anAmount] ifFalse: [self class TivExCheckingAccountOverdrawn signalWithArguments: (OrderedCollection with:self with:(Association key:'balance' value:self balance) with:(Association key:'amount' value:self amount))].
The sample will generate a TivExCheckingAccountOverdrawn exception when the following is executed:
TivSampleExceptionsCheckingAccount new withdraw: 10000.
The sample will generate a TivExCheckingAccountInsuredAmountExceeded exception when the following is executed:
TivSampleExceptionsCheckingAccount new deposit: 500000.
Note: | The Tivoli Application System Error events that are generated by these exceptions are logged to the file, TECEIF.LOG. |