mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-02 15:46:17 +01:00
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
This commit is contained in:
parent
7966f27882
commit
a12f546b3b
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user