common REFACTOR put all NETCONF-specific errors together
diff --git a/src/common.h b/src/common.h
index f03535d..d3623e1 100644
--- a/src/common.h
+++ b/src/common.h
@@ -262,12 +262,18 @@
#define LY_VCODE_DEV_NOT_PRESENT LYVE_REFERENCE, "Invalid deviation %s \"%s\" property \"%s\" which is not present."
-#define LY_VCODE_NOWHEN LYVE_DATA, "When condition \"%s\" not satisfied."
-#define LY_VCODE_NOMUST LYVE_DATA, "Must condition \"%s\" not satisfied."
-#define LY_VCODE_NOMAND LYVE_DATA, "Mandatory node \"%s\" instance does not exist."
-#define LY_VCODE_NOMIN LYVE_DATA, "Too few \"%s\" instances."
-#define LY_VCODE_NOMAX LYVE_DATA, "Too many \"%s\" instances."
+/* RFC 7950 section 15 errors (errmsg is used in type plugin validation callbacks) */
#define LY_VCODE_NOUNIQ LYVE_DATA, "Unique data leaf(s) \"%s\" not satisfied in \"%s\" and \"%s\"."
+#define LY_VCODE_NOMAX LYVE_DATA, "Too many \"%s\" instances."
+#define LY_VCODE_NOMIN LYVE_DATA, "Too few \"%s\" instances."
+#define LY_VCODE_NOMUST LYVE_DATA, "Must condition \"%s\" not satisfied."
+#define LY_ERRMSG_NOLREF_VAL /* LYVE_DATA */ "Invalid leafref value \"%s\" - no target instance \"%s\" with the same value."
+#define LY_ERRMSG_NOLREF_INST /* LYVE_DATA */ "Invalid leafref value \"%s\" - no existing target instance \"%s\"."
+#define LY_ERRMSG_NOINST /* LYVE_DATA */ "Invalid instance-identifier \"%s\" value - required instance not found."
+#define LY_VCODE_NOMAND_CHOIC LYVE_DATA, "Mandatory choice \"%s\" data do not exist."
+
+#define LY_VCODE_NOWHEN LYVE_DATA, "When condition \"%s\" not satisfied."
+#define LY_VCODE_NOMAND LYVE_DATA, "Mandatory node \"%s\" instance does not exist."
#define LY_VCODE_DUP LYVE_DATA, "Duplicate instance of \"%s\"."
#define LY_VCODE_DUPCASE LYVE_DATA, "Data for both cases \"%s\" and \"%s\" exist."
#define LY_VCODE_INNODE LYVE_DATA, "Invalid %s data node \"%s\" found."
diff --git a/src/plugins_types.c b/src/plugins_types.c
index f6ce96c..f78e4c4 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -1696,7 +1696,7 @@
/* find the target in data */
ret = ly_path_eval(storage->target, tree, NULL);
if (ret) {
- if (asprintf(&errmsg, "Invalid instance-identifier \"%s\" value - required instance not found.", storage->canonical) == -1) {
+ if (asprintf(&errmsg, LY_ERRMSG_NOINST, storage->canonical) == -1) {
*err = ly_err_new(LY_LLERR, LY_EMEM, 0, LY_EMEM_MSG, NULL, NULL);
ret = LY_EMEM;
} else {
@@ -1960,11 +1960,9 @@
ret = LY_ENOTFOUND;
val_str = lref->plugin->print(value, LY_PREF_JSON, NULL, &dynamic);
if (set.used) {
- rc = asprintf(errmsg, "Invalid leafref value \"%s\" - no target instance \"%s\" with the same value.",
- val_str, lref->path->expr);
+ rc = asprintf(errmsg, LY_ERRMSG_NOLREF_VAL, val_str, lref->path->expr);
} else {
- rc = asprintf(errmsg, "Invalid leafref value \"%s\" - no existing target instance \"%s\".",
- val_str, lref->path->expr);
+ rc = asprintf(errmsg, LY_ERRMSG_NOLREF_INST, val_str, lref->path->expr);
}
if (rc == -1) {
*errmsg = NULL;
diff --git a/src/validation.c b/src/validation.c
index 6120f42..4bd196a 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -713,7 +713,11 @@
if (!disabled) {
/* node instance not found */
- LOGVAL(snode->module->ctx, LY_VCODE_NOMAND, snode->name);
+ if (snode->nodetype == LYS_CHOICE) {
+ LOGVAL(snode->module->ctx, LY_VCODE_NOMAND_CHOIC, snode->name);
+ } else {
+ LOGVAL(snode->module->ctx, LY_VCODE_NOMAND, snode->name);
+ }
return LY_EVALID;
}