Loading...
Searching...
No Matches
Error information

## Data Structures

struct | ly_err_item
| Libyang full error structure. More...

## Enumerations

enum | LY_ERR { LY_SUCCESS = 0 , LY_EMEM , LY_ESYS , LY_EINVAL , LY_EEXIST , LY_ENOTFOUND , LY_EINT , LY_EVALID , LY_EDENIED , LY_EINCOMPLETE , LY_ERECOMPILE , LY_ENOT , LY_EOTHER , LY_EPLUGIN = 128 }
| libyang's error codes returned by the libyang functions. More...

## Functions

LIBYANG_API_DECL void | ly_err_clean (struct ly_ctx *ctx, struct ly_err_item *eitem)
| Free error structures from a context.
LIBYANG_API_DECL const struct ly_err_item * | ly_err_first (const struct ly_ctx *ctx)
| Get the first (thread, context-specific) generated error structure.
LIBYANG_API_DECL const struct ly_err_item * | ly_err_last (const struct ly_ctx *ctx)
| Get the latest (thread, context-specific) generated error structure.
LIBYANG_API_DECL void | ly_err_print (const struct ly_ctx *ctx, const struct ly_err_item *eitem)
| Print the error structure as if just generated.
LIBYANG_API_DECL const char * | ly_last_logmsg (void)
| Get the last (thread-specific) full logged error message.
LIBYANG_API_DECL const char * | ly_strerr (LY_ERR err)
| Get human-readable error message for an error code.
LIBYANG_API_DECL const char * | ly_strvecode (LY_VECODE vecode)
| Get human-readable error message for a validation error code.

## Detailed Description

Structures and functions to allow error information processing.

## Data Structure Documentation

## ly_err_item

struct ly_err_item

Libyang full error structure.

Definition at line 282 of file log.h.

Data Fields
char * | apptag | error-app-tag, if any
char * | data_path | error data path related to the error, if any
LY_ERR | err | error code number
LY_LOG_LEVEL | level | error (message) log level
uint64_t | line | input line the error occured on, if available
char * | msg | error message
struct ly_err_item * | next | next error item
struct ly_err_item * | prev | previous error item, points to the last item for the ifrst item
char * | schema_path | error schema path related to the error, if any
LY_VECODE | vecode | validation error code, if any

## Enumeration Type Documentation

## LY_ERR

enum LY_ERR

libyang's error codes returned by the libyang functions.

Enumerator
LY_SUCCESS | no error, not set by functions, included just to complete LY_ERR enumeration
LY_EMEM | Memory allocation failure
LY_ESYS | System call failure
LY_EINVAL | Invalid value
LY_EEXIST | Item already exists
LY_ENOTFOUND | Item does not exists
LY_EINT | Internal error
LY_EVALID | Validation failure
LY_EDENIED | Operation is not allowed
LY_EINCOMPLETE | The operation did not fail, but for some reason it was not possible to finish it completely. According to the specific use case, the caller is usually supposed to perform the operation again.
LY_ERECOMPILE | The operation did not fail, but requires context recompilation before it can be completed. According to the specific use case, the caller should react appropriately.
LY_ENOT | Negative result
LY_EOTHER | Unknown error
LY_EPLUGIN | Error reported by a plugin - the highest bit in the first byte is set. This value is used ORed with one of the other LY_ERR value and can be simply masked.

Definition at line 237 of file log.h.

## Function Documentation

## ly_err_clean()

LIBYANG_API_DECL void ly_err_clean | ( | struct ly_ctx * | ctx,
|  | struct ly_err_item * | eitem
| ) |  |

Free error structures from a context.

If `eitem` is not set, free all the error structures.

Parameters

  [in] | ctx | Relative context.
  [in] | eitem | Oldest error structure to remove, optional.

## ly_err_first()

LIBYANG_API_DECL const struct ly_err_item * ly_err_first | ( | const struct ly_ctx * | ctx | ) |

Get the first (thread, context-specific) generated error structure.

Parameters

  [in] | ctx | Relative context.

Returns
  First error structure, NULL if none available.

## ly_err_last()

LIBYANG_API_DECL const struct ly_err_item * ly_err_last | ( | const struct ly_ctx * | ctx | ) |

Get the latest (thread, context-specific) generated error structure.

Parameters

  [in] | ctx | Relative context.

Returns
  Last error structure, NULL if none available.

## ly_err_print()

LIBYANG_API_DECL void ly_err_print | ( | const struct ly_ctx * | ctx,
|  | const struct ly_err_item * | eitem
| ) |  |

Print the error structure as if just generated.

Parameters

  [in] | ctx | Optional context to store the message in.
  [in] | eitem | Error item structure to print.

## ly_last_logmsg()

LIBYANG_API_DECL const char * ly_last_logmsg | ( | void |  | ) |

Get the last (thread-specific) full logged error message.

This function is useful for getting errors from functions that do not have any context accessible and includes any additional information such as the path or line where the error occurred.

Returns
  Last generated error message.

## ly_strerr()

LIBYANG_API_DECL const char * ly_strerr | ( | LY_ERR | err | ) |

Get human-readable error message for an error code.

Parameters

  [in] | err | Error code.

Returns
  String error message.

## ly_strvecode()

LIBYANG_API_DECL const char * ly_strvecode | ( | LY_VECODE | vecode | ) |

Get human-readable error message for a validation error code.

Parameters

  [in] | vecode | Validation error code.

Returns
  String error message.