Created On:  14 September 2012
 
Below is a sample script using SilkTest 13 Workbench .Net Script where error-handling is implemented.


Sample:
----------------------------------------------------
Public Module Main
    Dim _desktop As Desktop = Agent.Desktop

    Public Sub Main()
        Dim a As Integer = 0
        Dim b As Integer = 0
        Dim c As Integer = 0
  
        Try
            a = b \ c
            Catch exc As DivideByZeroException    
                msgbox ("A run-time error occurred")
            Finally
                msgbox ("We are there")
            End Try
    End Sub
End Module
----------------------------------------------------

Result:
----------------------------------------------------
Playback error in the .NET Script 'sampleScript':

System.DivideByZeroException:
"Attempted to divide by zero."
  at Main.Main() in Main.vb:line 10
----------------------------------------------------

The expected result is a pop-up window with "A run-time error occurred" message will appear.

To be able to handle the error-handling in SilkTest 13 Workbench, set “Catch Exceptions when Thrown” to NO in the playback settings. By default this is set to Automatic which would display the system error, not the error-handling implemented.

1. Go to Tools | Options 
2. Select Playback | General
3. Set “Catch Exceptions when Thrown” to NO

This should allow to catch the error-handling.

Incident #2577754