Altova XMLSpy 2024 Enterprise Edition

The Application API returns errors in two different ways:


The HRESULT returned by every API method

The IErrorInfo interface of the Application API


Every API method returns an HRESULT. This return value gives the caller information about errors during execution of the method. If the call was successful, the return value is S_OK. The HRESULT option is commonly used in C/C++ programs.


However, programming languages such as VisualBasic and scripting languages (and other high-level development environments) don't give the programmer access to the HRESULT return of a COM call. Such languages use the IErrorInfo interface, which is also supported by the Application API. If an error occurs, the Application API creates a new object that implements the IErrorInfo interface. The information provided by the IErrorInfo interface is imported by the development environment into its own error-handling mechanism.


For example, the JScript code listing below causes an error to be thrown by incorrectly declaring an array. Additional information about the error object is provided by its properties number and description.


try {
  var arr = new Array(-1);
catch (err) {
  WScript.Echo("Error : (" + (err.number & 0xffff) + ")" + err.description);


© 2018-2024 Altova GmbH