Troubleshooting
Problem
This document provides information on how to retrieve error messages and information from the IBM iSeries Access for Windows automation objects and Microsoft ActiveX controls.
Resolving The Problem
When an error occurs in a program that uses the IBM i Access Client Solutions Windows Application Package automation objects or Microsoft ActiveX controls, the error message can be retrieved. All of the error information must be included when you submit error reports to IBM Support. For more information about APIs and samples, see Programmer's Toolkit (installed with IBM i Access Client Solutions Windows Application Package).
Excerpt from the Programmer's Toolkit Documentation
Excerpt from the Programmer's Toolkit Documentation
If an error is detected, the standard automation error handling mechanism is used to signal the error. For all detected errors, the standard mechanism for retrieving object errors can be used. For example, with Visual Basic, the properties of the Err object can be accessed. The error number can be one of the standard error values or one of the IBM i Access unique values defined in cwbxHResultEnum (which can be found in the cwbxvbs.inc file distributed with the toolkit).
In addition to the standard automation error handling mechanism, IBM i Access for Windows objects, which make calls to lower-level routines, also contain an Errors collection containing:
- A return code
This return code is a value signaling the cause of the error. This value can be any value listed in cwbReturnCodeEnum. In addition, each component might have component-specific errors that can be returned. For example, data queues return values are defined in cwbdqReturnCodeEnum.
- A list of messages
This value is a list of any messages logged for the failure. Each message is stored in its own Error object. These messages could be PC or IBM i messages.
When an error occurs, objects containing an Errors collection property can access its methods and properties to determine whether more error information specific to IBM i Access for Windows is available.
Note
The Errors collection contains information for the most recent call. It is cleared upon entry of each method call and property access. In some cases, an error might not be generated but the Errors collection might contain warning information. These cases are documented in the corresponding method and property descriptions.
Sample Code:
In addition to the standard automation error handling mechanism, IBM i Access for Windows objects, which make calls to lower-level routines, also contain an Errors collection containing:
- A return code
This return code is a value signaling the cause of the error. This value can be any value listed in cwbReturnCodeEnum. In addition, each component might have component-specific errors that can be returned. For example, data queues return values are defined in cwbdqReturnCodeEnum.
- A list of messages
This value is a list of any messages logged for the failure. Each message is stored in its own Error object. These messages could be PC or IBM i messages.
When an error occurs, objects containing an Errors collection property can access its methods and properties to determine whether more error information specific to IBM i Access for Windows is available.
Note
The Errors collection contains information for the most recent call. It is cleared upon entry of each method call and property access. In some cases, an error might not be generated but the Errors collection might contain warning information. These cases are documented in the corresponding method and property descriptions.
Sample Code:
'code that uses some cwbx automation object...
...
On Error goto failed 'Direct run time exceptions to the error handler
cmd.Run "crtlib " & libName.Text 'Run a remote command using the command object
...
exit sub
failed:
'Catch the error thrown by a failing command and display the error information
DspCwbErr cmd.Errors
end sub
Public Sub DspCwbErr(cwbErrs As cwbx.Errors)
'The cwbx errors collection is available on most Client Access objects such as:
' System, DataQueue, KeyedDataQueue, Command, Program
'Retrieve and display all information associated with the error
Dim errorClass(99) As String
' Set up strings to display for error class
errorClass(0) = "Informational"
errorClass(1) = "Warning"
errorClass(2) = "Error"
errorClass(1) = "ErrorRetry"
errorClass(2) = "ErrorAbort"
errorClass(10) = "HostWarning"
errorClass(20) = "HostError"
errorClass(30) = "HostSevError"
errorClass(40) = "HostSevErrorAbend"
errorClass(50) = "HostJobAbend"
errorClass(60) = "HostSysStatus"
errorClass(70) = "HostDeviceIntegrity"
errorClass(80) = "HostSysAlert"
errorClass(90) = "HostSysIntegrity"
errorClass(99) = "HostActionRequired"
If cwbErrs.count = 0 then
'A standard automation exception was raised
MsgBox "Error Number: " & Err.Number & vbCr & _
"Error Description: " & Err.Description & vbCr & _
"Source: " & Err.Source
else
MsgBox "Retrieving information for Client Access return code: " & cwbErrs.ReturnCode
' Display the message text and class for each Client Access
' message returned
For Each cwberr In cwbErrs.Errors
MsgBox "Message Text: " & vbCr & cwberr.Text & vbCr & vbCr & _
"Message Class: " & vbCr & errorClass(cwberr.Class)
Next
end if
End Sub
[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Data Access","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Historical Number
20370214
Was this topic helpful?
Document Information
More support for:
IBM i
Software version:
Version Independent
Operating system(s):
IBM i
Document number:
641657
Modified date:
25 June 2021
UID
nas8N1017700
Manage My Notification Subscriptions