summaryrefslogtreecommitdiff
path: root/lib/libfrr.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2020-05-14 12:30:34 -0300
committerRenato Westphal <renato@opensourcerouting.org>2020-05-28 19:22:54 -0300
commitdf5eda3d8783a3436f43821a2840911d610fd89d (patch)
tree49cef5931b240472e6ac5b1c78da9fad2ccee0cf /lib/libfrr.c
parent13d6b9c1343a1f925e3ffd7be0938bf1f395b461 (diff)
lib: return human-readable error messages to the northbound clients
Instead of returning only error codes (e.g. NB_ERR_VALIDATION) to the northbound clients, do better than that and also return a human-readable error message. This should make FRR more automation-friendly since operators won't need to dig into system logs to find out what went wrong in the case of an error. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/libfrr.c')
-rw-r--r--lib/libfrr.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c
index d52cef3fe9..cac9929577 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -903,15 +903,17 @@ static int frr_config_read_in(struct thread *t)
*/
if (frr_get_cli_mode() == FRR_CLI_TRANSACTIONAL) {
struct nb_context context = {};
+ char errmsg[BUFSIZ] = {0};
int ret;
context.client = NB_CLIENT_CLI;
ret = nb_candidate_commit(&context, vty_shared_candidate_config,
- true, "Read configuration file",
- NULL);
+ true, "Read configuration file", NULL,
+ errmsg, sizeof(errmsg));
if (ret != NB_OK && ret != NB_ERR_NO_CHANGES)
- zlog_err("%s: failed to read configuration file.",
- __func__);
+ zlog_err(
+ "%s: failed to read configuration file: %s (%s)",
+ __func__, nb_err_name(ret), errmsg);
}
return 0;