1WAFFLE_INIT(3) Waffle Manual WAFFLE_INIT(3)
2
3
4
6 waffle_error, waffle_error_get_info, waffle_error_get_code,
7 waffle_error_to_string - Thread-local error state
8
10 #include <waffle.h>
11
12 enum waffle_error {...};
13
14 struct waffle_error_info {
15 enum waffle_error code;
16 const char *message;
17 size_t message_length;
18 };
19
20
21 const struct waffle_error_info* waffle_error_get_info(void);
22
23 enum waffle_error waffle_error_get_code(void);
24
25 const char* waffle_error_to_string(enum waffle_errore);
26
28 Waffle functions usually return either a bool, in which false indicates
29 failure, or a pointer, in which null indicates failure. In addition to
30 returning a flag indicating failure, most functions also clear and then
31 set some thread-local error state.
32
33 The only functions that do not alter waffle's error state are listed
34 here and are explicitly documented as such. All functions listed here
35 can be called before waffle has been successfully initialized with
36 waffle_init(3)
37
38 struct waffle_error_info
39 This struct contains the user-visible portion of waffle's
40 thread-local error state.
41
42 code may be any token from enum waffle_error.
43
44 message often contains a descriptive message about the error. It is
45 never null, though it may be the empty string.
46
47 message_length is the length of message according to strlen(3).
48
49 waffle_error_to_string()
50 Convert a waffle_error token to a string. For example, convert
51 WAFFLE_ERROR_UNKNOWN to "WAFFLE_ERROR_UNKNOWN". Return null if the
52 token is not a valid error token.
53
54 This function always sets the error code to WAFFLE_ERROR_NONE.
55
56 waffle_error_get_info()
57 Get information about the current thread's error state.
58
59 This function never returns null. The returned pointer becomes
60 invalid when the thread-local error state changes.
61
62 This function does not alter waffle's error state.
63
64 waffle_error_get_code()
65 Get the current thread's error code. Calling this function is
66 equivalent to obtaining the error code with
67 waffle_error_get_info()->code.
68
69 This function does not alter waffle's error state.
70
71 enum waffle_error
72 For reference, below is the complete list of waffle's error codes.
73
74 WAFFLE_NO_ERROR = 0x00
75 The function succeeded.
76
77 WAFFLE_ERROR_FATAL = 0x01
78 Waffle encountered a fatal error. All future waffle calls
79 result in undefined behavior.
80
81 WAFFLE_ERROR_UNKNOWN = 0x02
82 Waffle encountered an error for which it lacks an error code.
83 This is usually produced when an underlying native call, such
84 as XOpenDisplay(3), fails for an unknown reason.
85
86 WAFFLE_ERROR_INTERNAL = 0x03
87 You found a bug in waffle. Please report it. The error message,
88 obtained by waffle_error_get_info(), should contain a
89 description of the bug.
90
91 WAFFLE_ERROR_BAD_ALLOC = 0x04
9