background image
<< Exceptions - Writing an error-handling function | Exceptions - Enabling fault trapping >>
Exceptions - Programmatically logging an error
<< Exceptions - Writing an error-handling function | Exceptions - Enabling fault trapping >>
216
User's Guide
9 H
ANDLING
E
XCEPTIONS
Programmatically logging an error
The second line is the result of printing the information from ExceptData.
The rest of the lines show the processing of the information from
ExceptCalls.
And note that this testcase passes, because the error was handled locally and
not reraised.
Programmatically logging an error
Notice that some of the testcases in this chapter passed, even though an error
occurred, because they used their own error handler and did not specify to log
the error. If you want to handle errors locally and generate an error (that is,
log an error in the results file), you can do any of the following:
After you have handled the error, reraise it using the reraise statement
and let the default recovery system handle it
Call any of the following functions in your script:
Defining your own exceptions
In addition to using built-in exceptions, you can define your own exceptions
and generate them using the raise statement.
Consider the following testcase:
testcase raiseExample ()
STRING sTestValue = "xxx"
STRING sExpected = "yyy"
TestVerification (sExpected, sTestValue)
Function
Action
LogError (string)
Writes string to the results file as an error (displays
in red or italics, depending on platform) and
increments the error counter.
This function is called automatically if you don't
handle the error yourself.
LogWarning (string) Same as LogError, except it logs a warning, not an
error.
ExceptLog ( )
Calls LogError with the data from the most recent
exception.