sysrepo  2.2.170
YANG-based system repository for all-around configuration management.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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. More...
 
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(). More...
 
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. More...
 
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. More...
 

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:

Function Documentation

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]errNETCONF error to read.
[out]error_typeNETCONF error type.
[out]error_tagNETCONF error tag.
[out]error_app_tagNETCONF error app tag, set to NULL if none.
[out]error_pathNETCONF error path, set to NULL if none.
[out]error_messageNETCONF error message.
[out]error_info_elementsArray of NETCONF error info elements, set to NULL if none.
[out]error_info_valuesArray of NETCONF error info values, set to NULL if none.
[out]error_info_countNETCONF error info count of both error_info_elements and error_info_values.
Returns
Error code (SR_ERR_OK on success).
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.

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]sessionImplicit session provided in a callback.
[in]error_typeNETCONF error type.
[in]error_tagNETCONF error tag.
[in]error_app_tagOptional NETCONF error app tag.
[in]error_pathOptional NETCONF error path.
[in]error_messageNETCONF error message.
[in]error_info_countOptional 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).
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]sessionImplicit session provided in a callback.
[in]error_typeNETCONF error type.
[in]error_tagNETCONF error tag.
[in]error_app_tagOptional NETCONF error app tag.
[in]error_pathOptional NETCONF error path.
[in]error_messageNETCONF error message.
[in]error_info_countOptional count of elements in NETCONF error info. Also the sizes of error_info_elems and error_info_values.
[in]error_info_elemsOptional array of NETCONF error info elements.
[in]error_info_valuesOptional array of NETCONF error info values to set for error_info_elems.
Returns
Error code (SR_ERR_OK on success).