summaryrefslogtreecommitdiff
path: root/minecctl
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-01 08:07:18 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-01 08:07:18 +0200
commit86727730b8e4cfce2a4ecf2e787c8bf7f57af924 (patch)
tree9a2f5c93474600f85aa35606ae2b3856f8a08165 /minecctl
parentff9d60b0d5b27369073a329cd5ceb5d6c94bdf84 (diff)
Improve line/error reporting in server config parsing
Diffstat (limited to 'minecctl')
-rw-r--r--minecctl/misc-commands.c5
-rw-r--r--minecctl/server.c7
2 files changed, 8 insertions, 4 deletions
diff --git a/minecctl/misc-commands.c b/minecctl/misc-commands.c
index f7f2dea..a4188f9 100644
--- a/minecctl/misc-commands.c
+++ b/minecctl/misc-commands.c
@@ -20,6 +20,7 @@ bool do_list(struct cfg *cfg)
bool do_lint(struct cfg *cfg)
{
struct server *server;
+ const char *error;
bool rv = true;
/* server->scfg.filename check excludes servers created from cmdline */
@@ -32,8 +33,8 @@ bool do_lint(struct cfg *cfg)
/* FIXME: should return bool */
server_read_config(cfg, server);
- if (!scfg_validate(&server->scfg)) {
- error("%s: invalid", server->name);
+ if (!scfg_validate(&server->scfg, &error)) {
+ error("%s: invalid (%s)", server->name, error);
rv = false;
}
}
diff --git a/minecctl/server.c b/minecctl/server.c
index 21df7f4..658254f 100644
--- a/minecctl/server.c
+++ b/minecctl/server.c
@@ -10,6 +10,8 @@
void server_read_config(struct cfg *cfg, struct server *server)
{
+ unsigned lineno;
+ const char *error;
char buf[4096];
size_t off = 0;
ssize_t r;
@@ -47,8 +49,9 @@ void server_read_config(struct cfg *cfg, struct server *server)
buf[off] = '\0';
close(fd);
- if (!scfg_parse(&server->scfg, buf, NULL))
- die("Unable to parse %s", server->scfg.filename);
+ if (!scfg_parse(&server->scfg, buf, NULL, &lineno, &error))
+ die("Unable to parse %s, line %u: %s", server->scfg.filename,
+ lineno, error);
if (!server->scfg.rcon_password)
verbose("rcon password not found in %s", server->scfg.filename);