summaryrefslogtreecommitdiffstats
path: root/src/roof-error.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/roof-error.h')
-rw-r--r--src/roof-error.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/roof-error.h b/src/roof-error.h
new file mode 100644
index 0000000..418645c
--- /dev/null
+++ b/src/roof-error.h
@@ -0,0 +1,61 @@
+#ifndef __ROOF_ERROR_H
+#define __ROOF_ERROR_H
+
+#include <ufo/ufo.h>
+
+
+#define roof_print_error(error) do { \
+ g_warning("%s", error->message); \
+ g_error_free(error); \
+ error = NULL; \
+ } while (0)
+
+#define roof_set_error(error, type, ...) do { \
+ if (error) g_set_error(error, UFO_TASK_ERROR, UFO_TASK_ERROR_##type, __VA_ARGS__); \
+ } while (0)
+
+#define roof_error(error, type, ...) do { \
+ if (error) g_set_error(error, UFO_TASK_ERROR, UFO_TASK_ERROR_##type, __VA_ARGS__); \
+ return; \
+ } while (0)
+
+#define roof_propagate_error(error, err, ...) do { \
+ g_propagate_prefixed_error(error, err, __VA_ARGS__); \
+ return; \
+ } while (0)
+
+#define roof_error_with_retval(error, retval, type, ...) do { \
+ if (error) g_set_error(error, UFO_TASK_ERROR, UFO_TASK_ERROR_##type, __VA_ARGS__); \
+ return retval; \
+ } while (0)
+
+#define roof_propagate_error_with_retval(error, retval, err, ...) do { \
+ g_propagate_prefixed_error(error, err, __VA_ARGS__); \
+ return retval; \
+ } while (0)
+
+
+#define roof_setup_error(error, ...) \
+ roof_error(error, SETUP, __VA_ARGS__)
+
+#define roof_setup_error_with_retval(error, ...) \
+ roof_error_with_retval(error, retval, SETUP, __VA_ARGS__)
+
+#define roof_new_error(error, ...) \
+ roof_error_with_retval(error, NULL, SETUP, __VA_ARGS__)
+
+
+#define roof_network_error(error, ...) \
+ roof_error(error, SETUP, __VA_ARGS__)
+
+#define root_set_network_error(error, ...) \
+ roof_set_error(error, SETUP, __VA_ARGS__)
+
+#define roof_network_error_with_retval(error, retval, ...) \
+ roof_error_with_retval(error, retval, SETUP, __VA_ARGS__)
+
+#define roof_memory_error(error, ...) \
+ roof_error(error, SETUP, __VA_ARGS__)
+
+
+#endif /* __ROOF_ERROR_H */