The UModel API returns errors in two different ways. Every API method returns an HRESULT. This return value informs the caller about any errors during the execution of the method. If the call was successful, the return value is equal to S_OK. C/C++ programmers generally use HRESULT to detect errors.
VisualBasic, scripting languages, and other high-level development environments do not give the programmer access to the returning HRESULT of a COM call. They use the second error-raising mechanism supported by the UModel API, the IErrorInfo interface. If an error occurs, the API creates a new object that implements the IErrorInfo interface. The development environment takes this interface and fills its own error-handling mechanism with the provided information.
The example code listings below show how to deal with errors raised from the UModel API in different development environments.
A common way to handle errors in VisualBasic is to define an error handler. This error handler can be set with the On Error statement. Usually the handler displays an error message and performs cleanup functions to avoid spare references and any kind of resource leaks.
VisualBasic fills its own Err object with the information from the IErrorInfo interface.
C/C++ gives you easy access to the HRESULT of the COM call and to the IErrorInterface.