summaryrefslogtreecommitdiffstats
path: root/src/roof-error.h
blob: 418645c22ad33280e894dd66805251ba5a9f10bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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 */