Error Handling
All ABBYY FineReader Engine 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 non-zero 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 provides a more detailed description of the error through the IErrorInfo interface.
- C++. FineReader Engine 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's interface, use the GetFREngineErrorInfo API function.
wchar_t* GetErrorMessage() { IErrorInfo* errorInfo; if( GetFREngineErrorInfo( 0, &errorInfo ) == S_OK && errorInfo != 0 ) { // Get error description wchar_t* description; errorInfo->GetDescription( &description ); errorInfo->Release(); return description; } else { return L"Unknown error"; } }
See also
7/3/2024 8:50:10 AM