aboutsummaryrefslogtreecommitdiff
path: root/error/include/error.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-02-25 15:11:23 -0800
committer3gg <3gg@shellblade.net>2024-02-25 15:11:23 -0800
commitd666c271bec412d700298200dbff22102c2bdd63 (patch)
tree8193d7f383d839ecd89dbd81a7e475b15fbf81b5 /error/include/error.h
parentf24912296c473ac15c12e65c97007fe3ece87dfa (diff)
Simpler error logging API.
Diffstat (limited to 'error/include/error.h')
-rw-r--r--error/include/error.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/error/include/error.h b/error/include/error.h
index 92c06ff..23df5f3 100644
--- a/error/include/error.h
+++ b/error/include/error.h
@@ -6,17 +6,17 @@
6/// Get the last error. 6/// Get the last error.
7const char* get_error(void); 7const char* get_error(void);
8 8
9extern xlstring gfx_error; 9extern xlstring g_error;
10 10
11/// Set the last error. 11/// Log an error.
12#define set_error(...) \ 12#define log_error(...) \
13 gfx_error.length = snprintf(gfx_error.str, xlstring_size, __VA_ARGS__) 13 { \
14 14 if (g_error.length == 0) { \
15/// Prepend an error to the last error. 15 g_error.length = snprintf(g_error.str, xlstring_size, __VA_ARGS__); \
16#define prepend_error(...) \ 16 } else { \
17 { \ 17 xlstring head; \
18 xlstring head; \ 18 head.length = snprintf(head.str, xlstring_size, __VA_ARGS__); \
19 head.length = snprintf(head.str, xlstring_size, __VA_ARGS__); \ 19 xlstring_append(&head, xlstring_make(": ")); \
20 xlstring_append(&head, xlstring_make(": ")); \ 20 g_error = xlstring_concat(head, g_error); \
21 gfx_error = xlstring_concat(head, gfx_error); \ 21 } \
22 } 22 }