mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-14 19:55:12 +01:00
gresource: Factor out common error setting code
This makes it a bit easier to make sure all the translatable strings are kept in sync. It introduces no functional changes. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3465
This commit is contained in:
parent
ced5c6d960
commit
a839737fc8
@ -675,6 +675,16 @@ g_resource_load (const gchar *filename,
|
||||
return g_resource_new_from_table (table);
|
||||
}
|
||||
|
||||
static void
|
||||
set_error_not_found (GError **error,
|
||||
const char *path)
|
||||
{
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
}
|
||||
|
||||
/* The only error this can return is %G_RESOURCE_ERROR_NOT_FOUND. */
|
||||
static gboolean
|
||||
do_lookup (GResource *resource,
|
||||
const gchar *path,
|
||||
@ -702,9 +712,7 @@ do_lookup (GResource *resource,
|
||||
|
||||
if (value == NULL)
|
||||
{
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -963,10 +971,7 @@ g_resource_enumerate_children (GResource *resource,
|
||||
|
||||
if (*path == 0)
|
||||
{
|
||||
if (error)
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1003,10 +1008,7 @@ g_resource_enumerate_children (GResource *resource,
|
||||
|
||||
if (children == NULL)
|
||||
{
|
||||
if (error)
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1130,9 +1132,7 @@ g_resources_open_stream (const gchar *path,
|
||||
}
|
||||
|
||||
if (l == NULL)
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
|
||||
g_rw_lock_reader_unlock (&resources_lock);
|
||||
|
||||
@ -1202,9 +1202,7 @@ g_resources_lookup_data (const gchar *path,
|
||||
}
|
||||
|
||||
if (l == NULL)
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
|
||||
g_rw_lock_reader_unlock (&resources_lock);
|
||||
|
||||
@ -1275,10 +1273,7 @@ g_resources_enumerate_children (const gchar *path,
|
||||
|
||||
if (hash == NULL)
|
||||
{
|
||||
if (error)
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
@ -1357,9 +1352,7 @@ g_resources_get_info (const gchar *path,
|
||||
}
|
||||
|
||||
if (l == NULL)
|
||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
||||
_("The resource at “%s” does not exist"),
|
||||
path);
|
||||
set_error_not_found (error, path);
|
||||
|
||||
g_rw_lock_reader_unlock (&resources_lock);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user