libyang  2.0.112
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Errors Handling

The most of the API functions directly returns error code in the form of LY_ERR value. In addition, if the LY_EVALID error arises, additional validation error code is provided to categorize validation failures into several groups.

All the errors arisen in connection with manipulation with the context, YANG modules or YANG data, are recorded into the context and can be examined for the more detailed information. These records are stored as ly_err_item structures and they are not only context-specific, but also thread-specific.

Storing error information is tightly connected with logging. So the Logging options control if and which errors are stored in the context. By default, only the last error is recorded, so a new error replaces the previous one. This can be changed with LY_LOSTORE option set via ly_log_options(). Then, the errors are stored as a list preserving the previous error records. The stored records can be accessed using ly_err_last() or ly_err_first() functions. The ly_err_clean() is used to remove error records from the context.

To print a specific error information via libyang logger, there is ly_err_print().

To simplify access to the last error record in the context, there is a set of functions returning important error information.

API for this group of functions is described in the error information module.