MINOR: server: indicate when no address was expected for a server
When parsing a peers section, it's particularly difficult to make the
difference between the local peer which doesn't have any address, and
other peers which need one, and the error messages do not help because
with just:
peers foo
bind :8001
server foo 127.0.0.1:8001
server bar 127.0.0.2:8001
One can get such a confusing message when the local peer is "bar":
[peers.cfg:15] : 'server foo/bar' : unknown keyword '127.0.0.1:8001'.
It's not clear there why the other peer doesn't trigger an error.
With this commit we add a hint in the error message when no address
was expected. The error remains quite generic (since deep into the
server code) but at least the useer gets a hint about why the keyword
wasn't understood:
[peers.cfg:15] : 'server foo/bar' : unknown keyword '127.0.0.1:8001'.
Hint: no address was expected for this server.
diff --git a/src/server.c b/src/server.c
index df84579..5cf0eac 100644
--- a/src/server.c
+++ b/src/server.c
@@ -2753,10 +2753,14 @@
if (!kw) {
best = srv_find_best_kw(args[*cur_arg]);
if (best)
- ha_alert("unknown keyword '%s'; did you mean '%s' maybe ?\n",
- args[*cur_arg], best);
+ ha_alert("unknown keyword '%s'; did you mean '%s' maybe ?%s\n",
+ args[*cur_arg], best,
+ (parse_flags & SRV_PARSE_PARSE_ADDR) ? "" :
+ " Hint: no address was expected for this server.");
else
- ha_alert("unknown keyword '%s'.\n", args[*cur_arg]);
+ ha_alert("unknown keyword '%s'.%s\n", args[*cur_arg],
+ (parse_flags & SRV_PARSE_PARSE_ADDR) ? "" :
+ " Hint: no address was expected for this server.");
return ERR_ALERT | ERR_FATAL;
}