Skip to content

Commit 5b80645

Browse files
fanchanghumichalvasko
authored andcommitted
resolve BUGFIX must validation raises 2 errors if there is a error-message defined in it
1 parent 53a6aca commit 5b80645

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/common.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void ly_err_free_next(struct ly_ctx *ctx, struct ly_err_item *last_eitem);
6666
void ly_ilo_change(struct ly_ctx *ctx, enum int_log_opts new_ilo, enum int_log_opts *prev_ilo, struct ly_err_item **prev_last_eitem);
6767
void ly_ilo_restore(struct ly_ctx *ctx, enum int_log_opts prev_ilo, struct ly_err_item *prev_last_eitem, int keep_and_print);
6868
void ly_err_last_set_apptag(const struct ly_ctx *ctx, const char *apptag);
69+
void ly_err_last_set_msg(const struct ly_ctx *ctx, const char *msg);
6970
extern THREAD_LOCAL enum int_log_opts log_opt;
7071

7172
/*

src/log.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,3 +1074,18 @@ ly_err_last_set_apptag(const struct ly_ctx *ctx, const char *apptag)
10741074
}
10751075
}
10761076
}
1077+
1078+
void
1079+
ly_err_last_set_msg(const struct ly_ctx *ctx, const char *msg)
1080+
{
1081+
struct ly_err_item *i;
1082+
1083+
if (log_opt != ILO_IGNORE) {
1084+
i = ly_err_first(ctx);
1085+
if (i) {
1086+
i = i->prev;
1087+
free(i->msg);
1088+
i->msg = strdup(msg);
1089+
}
1090+
}
1091+
}

src/resolve.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6353,7 +6353,7 @@ resolve_must(struct lyd_node *node, int inout_parent, int ignore_fail, int multi
63536353
} else {
63546354
LOGVAL(ctx, LYE_NOMUST, LY_VLOG_LYD, node, must[i].expr);
63556355
if (must[i].emsg) {
6356-
ly_vlog_str(ctx, LY_VLOG_PREV, must[i].emsg);
6356+
ly_err_last_set_msg(ctx, must[i].emsg);
63576357
}
63586358
if (must[i].eapptag) {
63596359
ly_err_last_set_apptag(ctx, must[i].eapptag);

0 commit comments

Comments
 (0)