Error handling is fully based on exceptions using try ... catch blocks.
The following code shows how to catch and evaluate errors that might occur when reading an image from file. The call to ReadImage is encapsulated by a try block; the error code of the exception is evaluated in a corresponding catch block. For more information on HALCON error codes please refer to the Extension Package Programmer's Manual.
try { image.ReadImage(filename); } catch (HException &except) { if (except.ErrorCode() == H_ERR_FNF) { // Handle file not found error } else { // Pass on unexpected error to caller throw except; } }