mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-28 02:20:04 +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);
|
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
|
static gboolean
|
||||||
do_lookup (GResource *resource,
|
do_lookup (GResource *resource,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
@ -702,9 +712,7 @@ do_lookup (GResource *resource,
|
|||||||
|
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
set_error_not_found (error, path);
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -963,10 +971,7 @@ g_resource_enumerate_children (GResource *resource,
|
|||||||
|
|
||||||
if (*path == 0)
|
if (*path == 0)
|
||||||
{
|
{
|
||||||
if (error)
|
set_error_not_found (error, path);
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,10 +1008,7 @@ g_resource_enumerate_children (GResource *resource,
|
|||||||
|
|
||||||
if (children == NULL)
|
if (children == NULL)
|
||||||
{
|
{
|
||||||
if (error)
|
set_error_not_found (error, path);
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,9 +1132,7 @@ g_resources_open_stream (const gchar *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
set_error_not_found (error, path);
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
|
|
||||||
g_rw_lock_reader_unlock (&resources_lock);
|
g_rw_lock_reader_unlock (&resources_lock);
|
||||||
|
|
||||||
@ -1202,9 +1202,7 @@ g_resources_lookup_data (const gchar *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
set_error_not_found (error, path);
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
|
|
||||||
g_rw_lock_reader_unlock (&resources_lock);
|
g_rw_lock_reader_unlock (&resources_lock);
|
||||||
|
|
||||||
@ -1275,10 +1273,7 @@ g_resources_enumerate_children (const gchar *path,
|
|||||||
|
|
||||||
if (hash == NULL)
|
if (hash == NULL)
|
||||||
{
|
{
|
||||||
if (error)
|
set_error_not_found (error, path);
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1357,9 +1352,7 @@ g_resources_get_info (const gchar *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
g_set_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND,
|
set_error_not_found (error, path);
|
||||||
_("The resource at “%s” does not exist"),
|
|
||||||
path);
|
|
||||||
|
|
||||||
g_rw_lock_reader_unlock (&resources_lock);
|
g_rw_lock_reader_unlock (&resources_lock);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user