aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-09-28 00:14:11 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-09-28 00:14:11 +0200
commit474bcb518ad93aa32a0c63d3d71ffe50e908ae65 (patch)
treec845bfa0429340b015428b0cd5724af3d1a711d3 /src
parente14c9af40f6e07926cecbfe8b82a0d15ea9c6022 (diff)
downloadtdv-474bcb518ad93aa32a0c63d3d71ffe50e908ae65.tar.gz
tdv-474bcb518ad93aa32a0c63d3d71ffe50e908ae65.tar.xz
tdv-474bcb518ad93aa32a0c63d3d71ffe50e908ae65.zip
Make app_load_config() return any error
Diffstat (limited to 'src')
-rw-r--r--src/sdtui.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index b7a54da..c4c39a8 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -317,7 +317,7 @@ app_load_config_values (Application *self, GKeyFile *kf)
}
static void
-app_load_config (Application *self)
+app_load_config (Application *self, GError **e)
{
GKeyFile *kf = g_key_file_new ();
GPtrArray *paths = g_ptr_array_new ();
@@ -330,22 +330,20 @@ app_load_config (Application *self)
// XXX: if there are dashes in the final path component,
// the function tries to replace them with directory separators,
// which is completely undocumented
- GError *e = NULL;
+ GError *error = NULL;
g_key_file_load_from_dirs (kf,
PROJECT_NAME G_DIR_SEPARATOR_S PROJECT_NAME ".conf",
- (const gchar **) paths->pdata, NULL, 0, &e);
+ (const gchar **) paths->pdata, NULL, 0, &error);
g_ptr_array_free (paths, TRUE);
// TODO: proper error handling showing all relevant information;
// we can afford that here since the terminal hasn't been initialized yet
- if (e)
- {
- if (e->code != G_KEY_FILE_ERROR_NOT_FOUND)
- g_error ("%s: %s\n", _("Cannot load configuration"), e->message);
- g_error_free (e);
- }
- else
+ if (!error)
app_load_config_values (self, kf);
+ else if (error->code == G_KEY_FILE_ERROR_NOT_FOUND)
+ g_error_free (error);
+ else
+ g_propagate_error (e, error);
g_key_file_free (kf);
}
@@ -421,7 +419,13 @@ app_init (Application *self, AppOptions *options, const gchar *filename)
app_reload_view (self);
app_init_attrs (self);
- app_load_config (self);
+
+ app_load_config (self, &error);
+ if (error)
+ {
+ g_printerr ("%s: %s\n", _("Cannot load configuration"), error->message);
+ exit (EXIT_FAILURE);
+ }
}
static void