Muokkaa

Jaa


COM Error Handling in Java and Visual Basic

There are three interfaces and three functions that can be used in COM to provide error handling when programming in Java or Microsoft Visual Basic. In Java and Visual Basic, the method call does not return an HRESULT as the return value. Instead, these languages use the COM interfaces and functions to obtain HRESULT values and to handle errors or exceptions. (Exceptions are events beyond the program's control, such as file problems or invalid parameters.)

The three interfaces that provide support for HRESULTs are listed and described briefly in the following table.

Interface Description
ICreateErrorInfo
Sets error information.
IErrorInfo
Returns information from an error object.
ISupportErrorInfo
Identifies the object as supporting the IErrorInfo interface.

The three functions that provide support for HRESULTs are listed and described briefly in the following table.

Interface Description
CreateErrorInfo
Creates an instance of a generic error object.
GetErrorInfo
Obtains the error information pointer set by the previous call to SetErrorInfo in the current logical thread.
SetErrorInfo
Sets the error information object for the current thread of execution.

Error Handling in COM