There is also a mechanism to add some extended error information about the thread's current HALCON error. The function HSetExtendedErrorInfo
Herror HSetExtendedErrorInfo(Hproc_handle proc_handle, INT4_8 error_code, char const *error_message)
can be called immediately before the operator returns the error code with return return H_ERR_*. In this case the extended error information (error_code and error_message) will be set thread-locally and can be queried by the next call of the HALCON operator get_extended_error_info. The set information gets cleared by both the next occurring HALCON error or the next call of HSetExtendedErrorInfo.
In error_code, a user-defined error code can be set, e.g., a 3rd Party SDK error code or a 0 value (indicating that no extended error code is set).
In error_message, a user-defined error message can be specified, e.g., a 3rd Party SDK error message or an empty string "" (indicating that no extended error message is set).
An example of how to use HSetExtendedErrorInfo is provided in $HALCONEXAMPLES/extension_package/useropencl/source/CIPOpenCLFilter.c. An example of how to obtain the extended error information by means of get_extended_error_info is provided in $HALCONEXAMPLES/extension_package/useropencl/examples/testuseropencl.hdev.