[glib] keyfile: Add "in group" to GError message consistently
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] keyfile: Add "in group" to GError message consistently
- Date: Mon, 8 Dec 2014 03:00:48 +0000 (UTC)
commit a12f546b3bd32ae826306c4c7dbd931fe37ec632
Author: Colin Walters <walters verbum org>
Date: Sun Dec 7 16:00:55 2014 -0500
keyfile: Add "in group" to GError message consistently
This originated with https://github.com/GNOME/ostree/pull/23
It's nicer for the user if we also mention which group the expected
key would be in.
And in fact, every other error *except* _get_value() already had it.
https://bugzilla.gnome.org/show_bug.cgi?id=741226
glib/gkeyfile.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
index cc51eda..ed5ae21 100644
--- a/glib/gkeyfile.c
+++ b/glib/gkeyfile.c
@@ -1648,6 +1648,17 @@ g_key_file_get_groups (GKeyFile *key_file,
return groups;
}
+static void
+set_not_found_key_error (const char *group_name,
+ const char *key,
+ GError **error)
+{
+ g_set_error (error, G_KEY_FILE_ERROR,
+ G_KEY_FILE_ERROR_KEY_NOT_FOUND,
+ _("Key file does not have key '%s' in group '%s'"),
+ key, group_name);
+}
+
/**
* g_key_file_get_value:
* @key_file: a #GKeyFile
@@ -1699,9 +1710,7 @@ g_key_file_get_value (GKeyFile *key_file,
if (pair)
value = g_strdup (pair->value);
else
- g_set_error (error, G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_KEY_NOT_FOUND,
- _("Key file does not have key '%s'"), key);
+ set_not_found_key_error (group_name, key, error);
return value;
}
@@ -3082,10 +3091,7 @@ g_key_file_set_key_comment (GKeyFile *key_file,
if (key_node == NULL)
{
- g_set_error (error, G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_KEY_NOT_FOUND,
- _("Key file does not have key '%s' in group '%s'"),
- key, group->name);
+ set_not_found_key_error (group->name, key, error);
return FALSE;
}
@@ -3274,10 +3280,7 @@ g_key_file_get_key_comment (GKeyFile *key_file,
if (key_node == NULL)
{
- g_set_error (error, G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_KEY_NOT_FOUND,
- _("Key file does not have key '%s' in group '%s'"),
- key, group->name);
+ set_not_found_key_error (group->name, key, error);
return NULL;
}
@@ -3841,10 +3844,7 @@ g_key_file_remove_key (GKeyFile *key_file,
if (!pair)
{
- g_set_error (error, G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_KEY_NOT_FOUND,
- _("Key file does not have key '%s' in group '%s'"),
- key, group->name);
+ set_not_found_key_error (group->name, key, error);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]