From d666c271bec412d700298200dbff22102c2bdd63 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 25 Feb 2024 15:11:23 -0800 Subject: Simpler error logging API. --- error/include/error.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'error/include') 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 @@ /// Get the last error. const char* get_error(void); -extern xlstring gfx_error; +extern xlstring g_error; -/// Set the last error. -#define set_error(...) \ - gfx_error.length = snprintf(gfx_error.str, xlstring_size, __VA_ARGS__) - -/// Prepend an error to the last error. -#define prepend_error(...) \ - { \ - xlstring head; \ - head.length = snprintf(head.str, xlstring_size, __VA_ARGS__); \ - xlstring_append(&head, xlstring_make(": ")); \ - gfx_error = xlstring_concat(head, gfx_error); \ +/// Log an error. +#define log_error(...) \ + { \ + if (g_error.length == 0) { \ + g_error.length = snprintf(g_error.str, xlstring_size, __VA_ARGS__); \ + } else { \ + xlstring head; \ + head.length = snprintf(head.str, xlstring_size, __VA_ARGS__); \ + xlstring_append(&head, xlstring_make(": ")); \ + g_error = xlstring_concat(head, g_error); \ + } \ } -- cgit v1.2.3