Added function g_propagte_error to hand over local errors to the calling

2000-09-01  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* gerror.c, gerror.h (g_propagte_error): Added function
	g_propagte_error to hand over local errors to the calling
	function.
This commit is contained in:
Sebastian Wilhelmi 2000-09-01 12:47:42 +00:00 committed by Sebastian Wilhelmi
parent 3dcf39eb77
commit 21a498b1a5
12 changed files with 104 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -1,3 +1,9 @@
2000-09-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gerror.c, gerror.h (g_propagte_error): Added function
g_propagte_error to hand over local errors to the calling
function.
2000-08-31 Tor Lillqvist <tml@iki.fi> 2000-08-31 Tor Lillqvist <tml@iki.fi>
* glib.h * glib.h

View File

@ -117,6 +117,9 @@ g_error_matches (const GError *error,
error->code == code; error->code == code;
} }
#define ERROR_OVERWRITTEN_WARNING "GError set over the top of a previous GError or uninitialized memory.\n" \
"This indicates a bug in someone's code. You must ensure an error is NULL before it's set."
void void
g_set_error (GError **err, g_set_error (GError **err,
GQuark domain, GQuark domain,
@ -130,14 +133,28 @@ g_set_error (GError **err,
return; return;
if (*err != NULL) if (*err != NULL)
g_warning ("GError set over the top of a previous GError or uninitialized memory.\n" g_warning (ERROR_OVERWRITTEN_WARNING);
"This indicates a bug in someone's code. You must ensure an error is NULL before it's set.");
va_start (args, format); va_start (args, format);
*err = g_error_new_valist (domain, code, format, args); *err = g_error_new_valist (domain, code, format, args);
va_end (args); va_end (args);
} }
void
g_propagate_error (GError **dest,
GError *src)
{
g_return_if_fail (src != NULL);
if (dest == NULL)
return;
if (*dest != NULL)
g_warning (ERROR_OVERWRITTEN_WARNING);
*dest = src;
}
void void
g_clear_error (GError **err) g_clear_error (GError **err)
{ {

View File

@ -60,6 +60,11 @@ void g_set_error (GError **err,
const gchar *format, const gchar *format,
...) G_GNUC_PRINTF (4, 5); ...) G_GNUC_PRINTF (4, 5);
/* if (dest) *dest = src; also has some sanity checks.
*/
void g_propagate_error (GError **dest,
GError *src);
/* if (err && *err) { g_error_free(*err); *err = NULL; } */ /* if (err && *err) { g_error_free(*err); *err = NULL; } */
void g_clear_error (GError **err); void g_clear_error (GError **err);

View File

@ -117,6 +117,9 @@ g_error_matches (const GError *error,
error->code == code; error->code == code;
} }
#define ERROR_OVERWRITTEN_WARNING "GError set over the top of a previous GError or uninitialized memory.\n" \
"This indicates a bug in someone's code. You must ensure an error is NULL before it's set."
void void
g_set_error (GError **err, g_set_error (GError **err,
GQuark domain, GQuark domain,
@ -130,14 +133,28 @@ g_set_error (GError **err,
return; return;
if (*err != NULL) if (*err != NULL)
g_warning ("GError set over the top of a previous GError or uninitialized memory.\n" g_warning (ERROR_OVERWRITTEN_WARNING);
"This indicates a bug in someone's code. You must ensure an error is NULL before it's set.");
va_start (args, format); va_start (args, format);
*err = g_error_new_valist (domain, code, format, args); *err = g_error_new_valist (domain, code, format, args);
va_end (args); va_end (args);
} }
void
g_propagate_error (GError **dest,
GError *src)
{
g_return_if_fail (src != NULL);
if (dest == NULL)
return;
if (*dest != NULL)
g_warning (ERROR_OVERWRITTEN_WARNING);
*dest = src;
}
void void
g_clear_error (GError **err) g_clear_error (GError **err)
{ {

View File

@ -60,6 +60,11 @@ void g_set_error (GError **err,
const gchar *format, const gchar *format,
...) G_GNUC_PRINTF (4, 5); ...) G_GNUC_PRINTF (4, 5);
/* if (dest) *dest = src; also has some sanity checks.
*/
void g_propagate_error (GError **dest,
GError *src);
/* if (err && *err) { g_error_free(*err); *err = NULL; } */ /* if (err && *err) { g_error_free(*err); *err = NULL; } */
void g_clear_error (GError **err); void g_clear_error (GError **err);