Iray Programmer's Manual

Error handling

Detecting failures depends on the particular method in question.

Some methods indicate their success or failure by an integral return value, for example, mi::neuraylib::INeuray::start(), as already seen in:

The general rule is that 0 indicates success, and all other values indicate failure.

Methods returning interface pointers indicate failure by a NULL pointer. Therefore you should check returned pointers for NULL. If you use the provided handle class, you can do so by calling mi::base::Handle::is_valid_interface().

Yet other methods report errors in more specialized ways, such as the importer methods on the mi::neuraylib::IImport_api interface, which return a mi::IImport_result object to handle sophisticated error reporting on file imports.

example_configuration.cpp and subsequent examples use a helper macro called check_success() to check for errors. If the condition is not true, the macro prints an error message and exits.

Note: For production software, thorough error-handling needs to be done. Detailed error-handling is omitted in the examples for simplicity.