Skip to content

Commit 6df71ed

Browse files
committed
common BUGFIX handle errors without message
1 parent f462375 commit 6df71ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,16 +1677,18 @@ np_reply_err_sr(sr_session_ctx_t *session, const char *rpc_name)
16771677
free(err_info_elem);
16781678
free(err_info_val);
16791679
} else {
1680+
err_msg = err_info->err[i].message ? err_info->err[i].message : sr_strerror(err_info->err[i].err_code);
1681+
16801682
/* get path */
1681-
if ((ptr = strstr(err_info->err[i].message, "(path \""))) {
1683+
if ((ptr = strstr(err_msg, "(path \""))) {
16821684
ptr += 7;
16831685
}
16841686
if (ptr) {
16851687
path = strndup(ptr, strchr(ptr, '\"') - ptr);
16861688
}
16871689

16881690
/* sysrepo/libyang error, create a NETCONF error if possible */
1689-
e = np_err(ly_ctx, err_info->err[i].message, err_info->err[i].err_code, path, rpc_name);
1691+
e = np_err(ly_ctx, err_msg, err_info->err[i].err_code, path, rpc_name);
16901692
free(path);
16911693
path = NULL;
16921694
}

0 commit comments

Comments
 (0)