summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-05-09 10:24:47 -0500
committerMatthew Barnes <mbarnes@redhat.com>2010-05-09 10:30:07 -0500
commit4f99bcad61ebc49ae520414a32372f84605baf6b (patch)
tree80035388aeefeee1573393bd2e319a060db3f443
parentb06dbcfab9d5dbd0ca8d7979472010ce2aca6248 (diff)
downloadevolution-data-server-4f99bcad61ebc49ae520414a32372f84605baf6b.tar.gz
Disallow overwriting one CamelException with another.
Make CamelException behave more like GError: accept the first error and reject subsequent errors with a runtime warning, unless the first error is cleared first. This may expose existing error handling bugs in the Camel providers, but that's what we want: fixing these bugs will smooth the transition to GError.
-rw-r--r--camel/camel-exception.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/camel/camel-exception.c b/camel/camel-exception.c
index 22db7f503..bc91a494f 100644
--- a/camel/camel-exception.c
+++ b/camel/camel-exception.c
@@ -36,6 +36,12 @@
/* dont turn this off */
#define w(x) x
+#define ERROR_OVERWRITTEN_WARNING \
+ "CamelException set over top of a previous CamelException.\n" \
+ "This indicates a bug in someone's code. You must ensure a " \
+ "CamelException is clear before it's set.\n" \
+ "The overwriting error message was: %s"
+
/**
* camel_exception_new: allocate a new exception object.
*
@@ -133,6 +139,12 @@ camel_exception_set (CamelException *ex, ExceptionId id, const gchar *desc)
printf("CamelException.set(%p, %u, '%s')\n", (gpointer) ex, id, desc);
if (!ex)
return;
+
+ if (camel_exception_is_set (ex)) {
+ g_warning (ERROR_OVERWRITTEN_WARNING, desc);
+ return;
+ }
+
ex->id = id;
if (desc != ex->desc) {
g_free (ex->desc);
@@ -178,6 +190,11 @@ camel_exception_setv (CamelException *ex, ExceptionId id, const gchar *format, .
return;
}
+ if (camel_exception_is_set (ex)) {
+ g_warning (ERROR_OVERWRITTEN_WARNING, desc);
+ return;
+ }
+
g_free(ex->desc);
ex->desc = desc;
ex->id = id;
@@ -207,6 +224,11 @@ camel_exception_xfer (CamelException *ex_dst,
return;
}
+ if (camel_exception_is_set (ex_dst)) {
+ g_warning (ERROR_OVERWRITTEN_WARNING, ex_src->desc);
+ return;
+ }
+
if (ex_dst->desc)
g_free (ex_dst->desc);