summaryrefslogtreecommitdiff
path: root/lib/yang.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2023-11-14 19:55:00 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2023-11-15 03:27:32 +0100
commit81cb39a9344aadfb644ee77d8f41929da0e5f82a (patch)
tree5f6b8e1b69f06a58bf1df243b7f3a26a7475a109 /lib/yang.c
parent858cc75b434344ae0b25eccaf6eef03debe4a031 (diff)
lib: fix printing multiple yang errors
When printing multiple YANG errors, we should print paths for all of them, not only for the last one. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/yang.c')
-rw-r--r--lib/yang.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/yang.c b/lib/yang.c
index 7046091baa..131d89cdfa 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -676,7 +676,6 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
const char *yang_print_errors(struct ly_ctx *ly_ctx, char *buf, size_t buf_len)
{
struct ly_err_item *ei;
- const char *path;
ei = ly_err_first(ly_ctx);
if (!ei)
@@ -684,18 +683,16 @@ const char *yang_print_errors(struct ly_ctx *ly_ctx, char *buf, size_t buf_len)
strlcpy(buf, "YANG error(s):\n", buf_len);
for (; ei; ei = ei->next) {
- strlcat(buf, " ", buf_len);
+ if (ei->path) {
+ strlcat(buf, " Path: ", buf_len);
+ strlcat(buf, ei->path, buf_len);
+ strlcat(buf, "\n", buf_len);
+ }
+ strlcat(buf, " Error: ", buf_len);
strlcat(buf, ei->msg, buf_len);
strlcat(buf, "\n", buf_len);
}
- path = ly_errpath(ly_ctx);
- if (path) {
- strlcat(buf, " YANG path: ", buf_len);
- strlcat(buf, path, buf_len);
- strlcat(buf, "\n", buf_len);
- }
-
ly_err_clean(ly_ctx, NULL);
return buf;