Share this page

# Example: Error Handling

This example demonstrates how you can display a standard error message. Error handling should be added to each workflow script that you write, because errors that are not detected by the workflow code can cause the user's browser to crash.

The user-defined function PrintError receives the name of the calling procedure as a parameter. If an error has occurred, PrintError prints out the error number, description and severity, and the name of the procedure in which the error occurred.

You do not need to create an Err object, because it is intrinsic to VBScript. For details about the Err object, refer to the Microsoft documentation.

    Sub PrintError(strFunctionName)
            If Err.Number <> 0 Then
                MsgBox "Error #" & Err.Number & ": " & Err.Description, _
                vbOKOnly+vbCritical, _
                "Workflow Error in Function " & strFunctionName
            End If
    End Sub

The following code segment illustrates how you can add error handling to your subroutines.

    Sub <sub_name>()
            On Error Resume Next
            ...
            [Your code here]
            ...
            PrintError "<sub_name>"
    End Sub

The following code segment illustrates how you can add error handling to your functions.

    Function <function_name>()
            On Error Resume Next
            ...
            [Your code here]
            ...
            PrintError "<function_name>"
    End Function

https://admhelp.microfocus.com ALM 8942
Tips to improve your search results... ALM Help Center ALM Help Center ALM Help 15.5-15.5.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: