Commit a8786011 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

don't overwrite errors

2001-02-09  Havoc Pennington  <hp@redhat.com>

	* gconvert.c (g_convert): don't overwrite errors

	* gerror.c (g_set_error): improve warning message if an error is
	overwritten
	(g_propagate_error): ditto
parent 41e2001d
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
2001-02-09 Havoc Pennington <hp@redhat.com>
* gconvert.c (g_convert): don't overwrite errors
* gerror.c (g_set_error): improve warning message if an error is
overwritten
(g_propagate_error): ditto
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c, gthread.h: Added functions g_static_rec_mutex_init,
......
......@@ -233,9 +233,12 @@ g_convert (const gchar *str,
{
if ((p - str) != len)
{
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
_("Partial character sequence at end of input"));
have_error = TRUE;
if (!have_error)
{
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
_("Partial character sequence at end of input"));
have_error = TRUE;
}
}
}
......@@ -337,6 +340,8 @@ g_convert_with_fallback (const gchar *str,
else
g_error_free (local_error);
local_error = NULL;
/* No go; to proceed, we need a converter from "UTF-8" to
* to_codeset, and the string as UTF-8.
*/
......
......@@ -169,7 +169,8 @@ g_error_matches (const GError *error,
}
#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."
"This indicates a bug in someone's code. You must ensure an error is NULL before it's set.\n" \
"The overwriting error message was: %s"
/**
* g_set_error:
......@@ -189,17 +190,21 @@ g_set_error (GError **err,
const gchar *format,
...)
{
GError *new;
va_list args;
if (err == NULL)
return;
if (*err != NULL)
g_warning (ERROR_OVERWRITTEN_WARNING);
va_start (args, format);
*err = g_error_new_valist (domain, code, format, args);
new = g_error_new_valist (domain, code, format, args);
va_end (args);
if (*err == NULL)
*err = new;
else
g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
}
/**
......@@ -225,9 +230,9 @@ g_propagate_error (GError **dest,
else
{
if (*dest != NULL)
g_warning (ERROR_OVERWRITTEN_WARNING);
*dest = src;
g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
else
*dest = src;
}
}
......
......@@ -233,9 +233,12 @@ g_convert (const gchar *str,
{
if ((p - str) != len)
{
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
_("Partial character sequence at end of input"));
have_error = TRUE;
if (!have_error)
{
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
_("Partial character sequence at end of input"));
have_error = TRUE;
}
}
}
......@@ -337,6 +340,8 @@ g_convert_with_fallback (const gchar *str,
else
g_error_free (local_error);
local_error = NULL;
/* No go; to proceed, we need a converter from "UTF-8" to
* to_codeset, and the string as UTF-8.
*/
......
......@@ -169,7 +169,8 @@ g_error_matches (const GError *error,
}
#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."
"This indicates a bug in someone's code. You must ensure an error is NULL before it's set.\n" \
"The overwriting error message was: %s"
/**
* g_set_error:
......@@ -189,17 +190,21 @@ g_set_error (GError **err,
const gchar *format,
...)
{
GError *new;
va_list args;
if (err == NULL)
return;
if (*err != NULL)
g_warning (ERROR_OVERWRITTEN_WARNING);
va_start (args, format);
*err = g_error_new_valist (domain, code, format, args);
new = g_error_new_valist (domain, code, format, args);
va_end (args);
if (*err == NULL)
*err = new;
else
g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
}
/**
......@@ -225,9 +230,9 @@ g_propagate_error (GError **dest,
else
{
if (*dest != NULL)
g_warning (ERROR_OVERWRITTEN_WARNING);
*dest = src;
g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
else
*dest = src;
}
}
......
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