[evolution-data-server] Add CAMEL_CHECK_LOCAL_GERROR.



commit 4c158822292689b98d593ea177c880123ed41fb0
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Dec 1 10:38:43 2013 -0500

    Add CAMEL_CHECK_LOCAL_GERROR.
    
    Same as CAMEL_CHECK_GERROR, but for direct GError pointers.
    
    Example:
    
        success = class->foo (object, some_data, &local_error);
        CAMEL_CHECK_LOCAL_GERROR (object, foo, success, local_error);
        return success;

 camel/camel-debug.h                     |   36 +++++++++++++++++++++++++++++++
 docs/reference/camel/camel-sections.txt |    1 +
 2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-debug.h b/camel/camel-debug.h
index a9027c4..87f8f3d 100644
--- a/camel/camel-debug.h
+++ b/camel/camel-debug.h
@@ -80,6 +80,42 @@ void camel_debug_end (void);
        } G_STMT_END
 
 /**
+ * CAMEL_CHECK_LOCAL_GERROR:
+ *
+ * Same as CAMEL_CHECK_GERROR, but for direct #GError pointers.
+ *
+ * Example:
+ *
+ *     success = class->foo (object, some_data, &local_error);
+ *     CAMEL_CHECK_LOCAL_GERROR (object, foo, success, local_error);
+ *     return success;
+ *
+ * Since: 3.12
+ */
+#define CAMEL_CHECK_LOCAL_GERROR(object, method, expr, error) \
+       G_STMT_START { \
+       if (expr) { \
+               if ((error) != NULL) { \
+                       g_warning ( \
+                               "%s::%s() set its GError " \
+                               "but then reported success", \
+                               G_OBJECT_TYPE_NAME (object), \
+                               G_STRINGIFY (method)); \
+                       g_warning ( \
+                               "Error message was: %s", \
+                               ((error))->message); \
+               } \
+       } else { \
+               if ((error) != NULL) { \
+                       g_warning ( \
+                               "%s::%s() reported failure " \
+                               "without setting its GError", \
+                               G_OBJECT_TYPE_NAME (object), \
+                               G_STRINGIFY (method)); \
+               } \
+       } \
+       } G_STMT_END
+/**
  * camel_pointer_tracker_track:
  * @ptr: pointer to add to pointer tracker
  *
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 06afe5e..c708753 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -2607,6 +2607,7 @@ camel_debug
 camel_debug_start
 camel_debug_end
 CAMEL_CHECK_GERROR
+CAMEL_CHECK_LOCAL_GERROR
 camel_pointer_tracker_track
 camel_pointer_tracker_track_with_info
 camel_pointer_tracker_untrack


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]