> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Error Handling

All ABBYY FlexiCapture SDK interface methods and properties return a value of the HRESULT type. The HRESULT (for result handle) is a way of returning success, warning, and error values. HRESULTs are really not handles to anything; they are only 32-bit values with several fields encoded in the value. A zero result indicates success and a nonzero result indicates failure.

If a method or property call was not successful, this method or property returns an HRESULT code that indicates the failure. Besides, it initializes the **IErrorInfo** object with a more detailed description of the error. Visual Basic users may access the HRESULT code through the *Number* property of the *Err* object. Other attributes of the *Err* object are initialized with the information from the **IErrorInfo**. Please refer to the documentation on COM for detailed description of error handling. The most general tips for it are the following:

* **Visual Basic**. Error handling here is performed with the use of the **On Error** statement. If you do not use the **On Error Resume Next** statement anywhere in your code, any run-time error that occurs can cause an error message from the **IErrorInfo** object to be displayed and code execution stopped.
* **Raw C++**. ABBYY FlexiCapture SDK interface methods and properties cannot throw exceptions but return HRESULTs. The most important means for handling these return codes are the SUCCEEDED and FAILED macros. They test the HRESULT value and deduce from it what was the result of the operation – success or failure. To get a pointer to the **IErrorInfo** object interface, use the **GetErrorInfo** API function.
* **C++ with the Native COM support**. The Native COM support technology translates the HRESULT codes of interface functions into exceptions of the special type - **\_com\_error**, and automatically uses information from the **IErrorInfo** object. Thus, a sequence of ABBYY FlexiCapture SDK methods may be enclosed by the statements:

  ```cpp theme={null}
  try {
      ...
  } catch (_com_error e) {
  ...
  }
  ```

If any method or property that was called from inside the **try-catch** block returns an error code, this leads to throwing the exception, and the code after erroneous statement is not executed, and control is transferred to the code after the **catch** statement. Generally, error handling with the Native COM support may be performed in a way standard for any C++ code using functions that may throw exceptions.

* **C#**. Automatically generated wrappers for COM interfaces detect errors and translate them to standard exceptions:

  ```csharp theme={null}
  try {
  …
  } catch( Exception e ) {
  ...
  }
  ```

## See also

[Standard Return Codes](https://docs.abbyy.com/flexi-capture/sdk/api-reference/errorcodes.md)
