Commit 21a498b1 authored by Sebastian Wilhelmi's avatar Sebastian Wilhelmi Committed by Sebastian Wilhelmi

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.
parent 3dcf39eb
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>
* glib.h
......
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>
* glib.h
......
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>
* glib.h
......
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>
* glib.h
......
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>
* glib.h
......
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>
* glib.h
......
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>
* glib.h
......
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>
* glib.h
......
......@@ -117,11 +117,14 @@ g_error_matches (const GError *error,
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
g_set_error (GError **err,
GQuark domain,
gint code,
const gchar *format,
g_set_error (GError **err,
GQuark domain,
gint code,
const gchar *format,
...)
{
va_list args;
......@@ -130,14 +133,28 @@ g_set_error (GError **err,
return;
if (*err != NULL)
g_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.");
g_warning (ERROR_OVERWRITTEN_WARNING);
va_start (args, format);
*err = g_error_new_valist (domain, code, format, 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
g_clear_error (GError **err)
{
......
......@@ -60,6 +60,11 @@ void g_set_error (GError **err,
const gchar *format,
...) 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; } */
void g_clear_error (GError **err);
......
......@@ -117,11 +117,14 @@ g_error_matches (const GError *error,
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
g_set_error (GError **err,
GQuark domain,
gint code,
const gchar *format,
g_set_error (GError **err,
GQuark domain,
gint code,
const gchar *format,
...)
{
va_list args;
......@@ -130,14 +133,28 @@ g_set_error (GError **err,
return;
if (*err != NULL)
g_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.");
g_warning (ERROR_OVERWRITTEN_WARNING);
va_start (args, format);
*err = g_error_new_valist (domain, code, format, 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
g_clear_error (GError **err)
{
......
......@@ -60,6 +60,11 @@ void g_set_error (GError **err,
const gchar *format,
...) 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; } */
void g_clear_error (GError **err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment