Loading...
Searching...
No Matches
Error Format Handling Utilities

## Functions

int | sr_err_get_netconf_error (const sr_error_info_err_t *err, const char **error_type, const char **error_tag, const char **error_app_tag, const char **error_path, const char **error_message, const char ***error_info_elements, const char ***error_info_values, uint32_t *error_info_count)
| Get NETCONF callback error.
int | sr_err_get_netconf_error_idx (const sr_error_info_err_t *err, uint32_t idx, const char **error_type, const char **error_tag, const char **error_app_tag, const char **error_path, const char **error_message, const char ***error_info_elements, const char ***error_info_values, uint32_t *error_info_count)
| Deprecated, every NETCONF error has its own `err`, use sr_err_get_netconf_error().
int | sr_session_set_netconf_error (sr_session_ctx_t *session, const char *error_type, const char *error_tag, const char *error_app_tag, const char *error_path, const char *error_message, uint32_t error_info_count,...)
| Set NETCONF callback error or add another if a NETCONF error has already been set. Specifically, sets the error message, error format, and error data encoding all the NETCONF-specific error information.
int | sr_session_set_netconf_error2 (sr_session_ctx_t *session, const char *error_type, const char *error_tag, const char *error_app_tag, const char *error_path, const char *error_message, uint32_t error_info_count, const char **error_info_elems, const char **error_info_values)
| Set NETCONF callback error or add another if a NETCONF error has already been set.
int | srplg_errinfo_set_netconf_error (sr_error_info_t **err_info, const char *error_type, const char *error_tag, const char *error_app_tag, const char *error_path, const char *error_message, uint32_t error_info_count,...)
| Set NETCONF plugin callback error or add another if a NETCONF error has already been set.
int | srplg_errinfo_set_netconf_error2 (sr_error_info_t **err_info, const char *error_type, const char *error_tag, const char *error_app_tag, const char *error_path, const char *error_message, uint32_t error_info_count, const char **error_info_elems, const char **error_info_values)
| Set NETCONF plugin callback error or add another if a NETCONF error has already been set.

## Detailed Description

Generally, if an application wants to communicate an error from a sysrepo callback, it must return an sr_error_t error value and may optionally set error message using sr_session_set_error_message(). Additionally, if more information needs to be communicated, arbitrary chunks of data can be written by sr_session_push_error_data(), which can then be decoded based on the error format set by sr_session_set_error_format().

To make writing specific errors easier, following is a list of well-known error formats, for which utility functions are provided that allow setting the whole error by a single function.

Well-known error formats:

- NETCONF

## Function Documentation

## sr_err_get_netconf_error()

int sr_err_get_netconf_error | ( | const sr_error_info_err_t * | err,
|  | const char ** | error_type,
|  | const char ** | error_tag,
|  | const char ** | error_app_tag,
|  | const char ** | error_path,
|  | const char ** | error_message,
|  | const char *** | error_info_elements,
|  | const char *** | error_info_values,
|  | uint32_t * | error_info_count )

Get NETCONF callback error.

Parameters

  [in] | err | NETCONF error to read.
  [out] | error_type | NETCONF error type.
  [out] | error_tag | NETCONF error tag.
  [out] | error_app_tag | NETCONF error app tag, set to NULL if none.
  [out] | error_path | NETCONF error path, set to NULL if none.
  [out] | error_message | NETCONF error message.
  [out] | error_info_elements | Array of NETCONF error info elements, set to NULL if none.
  [out] | error_info_values | Array of NETCONF error info values, set to NULL if none.
  [out] | error_info_count | NETCONF error info count of both `error_info_elements` and `error_info_values`.

Returns
  Error code (SR_ERR_OK on success).

## sr_err_get_netconf_error_idx()

int sr_err_get_netconf_error_idx | ( | const sr_error_info_err_t * | err,
|  | uint32_t | idx,
|  | const char ** | error_type,
|  | const char ** | error_tag,
|  | const char ** | error_app_tag,
|  | const char ** | error_path,
|  | const char ** | error_message,
|  | const char *** | error_info_elements,
|  | const char *** | error_info_values,
|  | uint32_t * | error_info_count )

Deprecated, every NETCONF error has its own `err`, use sr_err_get_netconf_error().

## sr_session_set_netconf_error()

int sr_session_set_netconf_error | ( | sr_session_ctx_t * | session,
|  | const char * | error_type,
|  | const char * | error_tag,
|  | const char * | error_app_tag,
|  | const char * | error_path,
|  | const char * | error_message,
|  | uint32_t | error_info_count,
|  |  | ... )

Set NETCONF callback error or add another if a NETCONF error has already been set. Specifically, sets the error message, error format, and error data encoding all the NETCONF-specific error information.

Meaning of each value corresponds to the definiition of NETCONF rpc-error element and value restrictions of `error_type` and `error_tag` are checked.

Parameters

  [in] | session | Implicit session provided in a callback.
  [in] | error_type | NETCONF error type.
  [in] | error_tag | NETCONF error tag.
  [in] | error_app_tag | Optional NETCONF error app tag.
  [in] | error_path | Optional NETCONF error path.
  [in] | error_message | NETCONF error message.
  [in] | error_info_count | Optional count of elements in NETCONF error info.
  [in] | ... | Optional NETCONF error info elements. There must be 2x `error_info_count` parameters. They create pairs of element-name and element-value to be set for the NETCONF error.

Returns
  Error code (SR_ERR_OK on success).

## sr_session_set_netconf_error2()

int sr_session_set_netconf_error2 | ( | sr_session_ctx_t * | session,
|  | const char * | error_type,
|  | const char * | error_tag,
|  | const char * | error_app_tag,
|  | const char * | error_path,
|  | const char * | error_message,
|  | uint32_t | error_info_count,
|  | const char ** | error_info_elems,
|  | const char ** | error_info_values )

Set NETCONF callback error or add another if a NETCONF error has already been set.

Similar functionality to sr_session_set_netconf_error().

Parameters

  [in] | session | Implicit session provided in a callback.
  [in] | error_type | NETCONF error type.
  [in] | error_tag | NETCONF error tag.
  [in] | error_app_tag | Optional NETCONF error app tag.
  [in] | error_path | Optional NETCONF error path.
  [in] | error_message | NETCONF error message.
  [in] | error_info_count | Optional count of elements in NETCONF error info. Also the sizes of `error_info_elems` and `error_info_values`.
  [in] | error_info_elems | Optional array of NETCONF error info elements.
  [in] | error_info_values | Optional array of NETCONF error info values to set for `error_info_elems`.

Returns
  Error code (SR_ERR_OK on success).

## srplg_errinfo_set_netconf_error()

int srplg_errinfo_set_netconf_error | ( | sr_error_info_t ** | err_info,
|  | const char * | error_type,
|  | const char * | error_tag,
|  | const char * | error_app_tag,
|  | const char * | error_path,
|  | const char * | error_message,
|  | uint32_t | error_info_count,
|  |  | ... )

Set NETCONF plugin callback error or add another if a NETCONF error has already been set.

Similar functionality to sr_session_set_netconf_error().

Parameters

  [in,out] | err_info | Error info to create or add to.
  [in] | error_type | NETCONF error type.
  [in] | error_tag | NETCONF error tag.
  [in] | error_app_tag | Optional NETCONF error app tag.
  [in] | error_path | Optional NETCONF error path.
  [in] | error_message | NETCONF error message.
  [in] | error_info_count | Optional count of elements in NETCONF error info.
  [in] | ... | Optional NETCONF error info elements. There must be 2x `error_info_count` parameters. They create pairs of element-name and element-value to be set for the NETCONF error.

Returns
  Error code (SR_ERR_OK on success).

## srplg_errinfo_set_netconf_error2()

int srplg_errinfo_set_netconf_error2 | ( | sr_error_info_t ** | err_info,
|  | const char * | error_type,
|  | const char * | error_tag,
|  | const char * | error_app_tag,
|  | const char * | error_path,
|  | const char * | error_message,
|  | uint32_t | error_info_count,
|  | const char ** | error_info_elems,
|  | const char ** | error_info_values )

Set NETCONF plugin callback error or add another if a NETCONF error has already been set.

Similar functionality to srplg_errinfo_set_netconf_error().

Parameters

  [in,out] | err_info | Error info to create or add to.
  [in] | error_type | NETCONF error type.
  [in] | error_tag | NETCONF error tag.
  [in] | error_app_tag | Optional NETCONF error app tag.
  [in] | error_path | Optional NETCONF error path.
  [in] | error_message | NETCONF error message.
  [in] | error_info_count | Optional count of elements in NETCONF error info. Also the sizes of `error_info_elems` and `error_info_values`.
  [in] | error_info_elems | Optional array of NETCONF error info elements.
  [in] | error_info_values | Optional array of NETCONF error info values to set for `error_info_elems`.

Returns
  Error code (SR_ERR_OK on success).