New feature: [Customized NETCONF error message](https://github.com/clicon/clixon/issues/454)
* Added new callback `.ca_errmsg` * Changed signature of `clicon_netconf_error()` and `netconf_err2cb()`
This commit is contained in:
parent
e7313fc9a2
commit
5bdad1870e
25 changed files with 258 additions and 122 deletions
|
|
@ -243,7 +243,7 @@ load_extraxml(clicon_handle h,
|
|||
if ((ret = xml_bind_yang(h, xt, YB_MODULE, yspec, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (netconf_err2cb(xerr, cbret) < 0)
|
||||
if (netconf_err2cb(h, xerr, cbret) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ cli_dbxml(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
cprintf(cb, "api-path syntax error \"%s\": ", api_path_fmt);
|
||||
if (netconf_err2cb(xerr, cb) < 0)
|
||||
if (netconf_err2cb(h, xerr, cb) < 0)
|
||||
goto done;
|
||||
clicon_err(OE_CFG, EINVAL, "%s", cbuf_get(cb));
|
||||
goto done;
|
||||
|
|
@ -946,13 +946,13 @@ compare_db_names(clicon_handle h,
|
|||
if (clicon_rpc_get_config(h, NULL, db1, "/", NULL, NULL, &xc1) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xc1, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
if (clicon_rpc_get_config(h, NULL, db2, "/", NULL, NULL, &xc2) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xc2, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* Note that XML and TEXT uses a (new) structured in-mem algorithm while
|
||||
|
|
@ -1120,7 +1120,7 @@ load_config_file(clicon_handle h,
|
|||
if ((ret = clixon_xml_parse_file(fp, YB_NONE, yspec, &xt, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clixon_netconf_error(xerr, "Loading", filename);
|
||||
clixon_netconf_error(h, xerr, "Loading", filename);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
|
@ -1128,7 +1128,7 @@ load_config_file(clicon_handle h,
|
|||
if ((ret = clixon_json_parse_file(fp, 1, YB_NONE, yspec, &xt, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clixon_netconf_error(xerr, "Loading", filename);
|
||||
clixon_netconf_error(h, xerr, "Loading", filename);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
|
@ -1139,7 +1139,7 @@ load_config_file(clicon_handle h,
|
|||
if ((ret = clixon_text_syntax_parse_file(fp, YB_MODULE_NEXT, yspec, &xt, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clixon_netconf_error(xerr, "Loading", filename);
|
||||
clixon_netconf_error(h, xerr, "Loading", filename);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
|
@ -1277,7 +1277,7 @@ save_config_file(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* get-config returns a <data> tree. Save as <config> tree so it can be used
|
||||
|
|
@ -1661,7 +1661,7 @@ cli_copy_config(clicon_handle h,
|
|||
if (clicon_rpc_get_config(h, NULL, db, cbuf_get(cb), nsc, NULL, &x1) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(x1, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -1874,7 +1874,7 @@ cli_process_control(clicon_handle h,
|
|||
if (clicon_rpc_netconf(h, cbuf_get(cb), &xret, NULL) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml2file(stdout, xml_child_i(xret, 0), 0, 1, NULL, cligen_output, 0, 1) < 0)
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ pipe_showas_fn(clicon_handle h,
|
|||
if ((ret = xml_bind_yang(h, xt, YB_MODULE, yspec, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clixon_netconf_error(xerr, "Parse top file", NULL);
|
||||
clixon_netconf_error(h, xerr, "Parse top file", NULL);
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ expand_dbvar(void *h,
|
|||
goto done;
|
||||
if (ret == 0){
|
||||
// XXX cf cli_dbxml
|
||||
clixon_netconf_error(xerr, "Expand datastore symbol", NULL);
|
||||
clixon_netconf_error(h, xerr, "Expand datastore symbol", NULL);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ expand_dbvar(void *h,
|
|||
if (clicon_rpc_get_config(h, NULL, dbstr, cbuf_get(cbxpath), nsc, NULL, &xt) < 0)
|
||||
goto done;
|
||||
if ((xe = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xe, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xe, "Get configuration", NULL);
|
||||
goto ok;
|
||||
}
|
||||
if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, cbuf_get(cbxpath)) < 0)
|
||||
|
|
@ -543,7 +543,7 @@ cli_show_common(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* Special tagged modes: strip wd:default=true attribute and (optionally) nodes associated with it */
|
||||
|
|
@ -1314,7 +1314,7 @@ cli_pagination(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xret, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
if (xpath_vec(xret, nsc, "%s", &xvec, &xlen, xpath) < 0)
|
||||
|
|
@ -1764,7 +1764,7 @@ cli_show_statistics(clicon_handle h,
|
|||
if (clicon_rpc_netconf(h, cbuf_get(cb), &xret, NULL) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
fprintf(stdout, "Backend:\n");
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ api_return_err(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
cprintf(cberr, "Internal error, system returned invalid error message: ");
|
||||
if (netconf_err2cb(xerr, cberr) < 0)
|
||||
if (netconf_err2cb(h, xerr, cberr) < 0)
|
||||
goto done;
|
||||
if (netconf_operation_failed_xml(&xerr2, "application",
|
||||
cbuf_get(cberr)) < 0)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ restconf_main_config(clicon_handle h,
|
|||
if (clicon_rpc_get_config(h, pw->pw_name, "running", "/restconf", nsc, NULL, &xconfig) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get backend restconf config", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get backend restconf config", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* Extract restconf configuration */
|
||||
|
|
|
|||
|
|
@ -679,7 +679,7 @@ restconf_clixon_backend(clicon_handle h,
|
|||
if (clicon_rpc_get_config(h, pw->pw_name, "running", "/restconf", nsc, NULL, &xconfig) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get backend restconf config", NULL);
|
||||
clixon_netconf_error(h, xerr, "Get backend restconf config", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* Extract restconf configuration */
|
||||
|
|
@ -1017,7 +1017,7 @@ restconf_clixon_init(clicon_handle h,
|
|||
if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clixon_netconf_error(xerr, "Inline restconf config", NULL);
|
||||
clixon_netconf_error(h, xerr, "Inline restconf config", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* Replace parent w first child */
|
||||
|
|
|
|||
|
|
@ -1214,7 +1214,7 @@ snmp_table_getnext(clicon_handle h,
|
|||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
|
||||
clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
|
||||
goto done;
|
||||
}
|
||||
if ((xtable = xpath_first(xt, nsc, "%s", xpath)) != NULL) {
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ mibyang_table_poll(clicon_handle h,
|
|||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
|
||||
clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
|
||||
goto done;
|
||||
}
|
||||
if ((xtable = xpath_first(xt, nsc, "%s", xpath)) != NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue