degesch: die on configuration parse errors

Seems more sensible.
This commit is contained in:
Přemysl Eric Janouch 2016-07-23 20:00:40 +02:00
parent beaf1a1f82
commit 483ab39e3c
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 8 additions and 5 deletions

View File

@ -12683,7 +12683,7 @@ load_configuration_file (const char *filename, struct error **e)
struct error *error = NULL; struct error *error = NULL;
if (!(root = config_item_parse (data.str, data.len, false, &error))) if (!(root = config_item_parse (data.str, data.len, false, &error)))
{ {
error_set (e, "Configuration parse error: %s", error->message); error_set (e, "Parsing `%s' failed: %s", filename, error->message);
error_free (error); error_free (error);
} }
end: end:
@ -12744,6 +12744,10 @@ load_default_aliases (struct app_context *ctx)
static void static void
load_configuration (struct app_context *ctx) load_configuration (struct app_context *ctx)
{ {
// In theory, we could ensure that only one instance is running by locking
// the configuration file and ensuring here that it exists. This is
// however brittle, as it may be unlinked without the application noticing.
struct config_item *root = NULL; struct config_item *root = NULL;
struct error *e = NULL; struct error *e = NULL;
@ -12758,11 +12762,10 @@ load_configuration (struct app_context *ctx)
if (e) if (e)
{ {
log_global_error (ctx, "#s", e->message); log_global_error (ctx, "#s", e->message);
log_global_error (ctx,
"Please either fix the configuration file or remove it", filename);
error_free (e); error_free (e);
exit (EXIT_FAILURE);
// That would be somewhat undesired
config_item_get (ctx->config.root, "behaviour.save_on_quit", NULL)
->value.boolean = false;
} }
if (root) if (root)