Generates an exception and either transfers control to an exception handler or halts the script.
raise[integer-expr[, expr[, cmd-line]]]
Variable | Description |
---|---|
integer-expr | Optional: The number of the exception you want to raise in the Error Handler. |
expr | Optional: An expression of any type that contains information about the exception. You can specify a string containing an explanation of the error, or you can get this information from Silk Test Classic by calling the built-in 4Test function, ExceptData, inside the Error Handler. |
cmd-line | Optional: An expression that contains a command line. If specified, the results file displays an icon on the error line. When you click the icon, the command line executes. |
The 11th line of raise.t is the line containing the raise function call and is therefore the location of the error and that the 5th line contains the call to the test case function in which the error occurred.
All implicit exceptions, which are those raised automatically by Silk Test Classic, contain an error message string as data and print this message to the error log and the Results window.
[-] testcase raiseExample() [ ] STRING sTestValue = "xxx" [ ] STRING sExpected = "yyy" [ ] TestVerification(sExpected, sTestValue) [ ] [-] TestVerification(STRING sExpected, STRING sTestValue) [-] if(sExpected == sTestValue) [ ] Print("Test was successful") [-] else [ ] raise 1, "ERROR: Test verification failed" [ ] // This script prints: [ ] // ERROR: Test verification failed [ ] // Occurred in TestVerification at raise.t(11) [ ] // Called from raiseExample at raise.t(5)