aboutsummaryrefslogtreecommitdiff
path: root/error/include/error.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2023-06-17 20:21:58 -0700
committer3gg <3gg@shellblade.net>2023-06-17 20:21:58 -0700
commit08ec3a7a1fdb16cbb52b05f934bd001ca38bd991 (patch)
tree664da276c93ae301c0bac038cd011afda6396ac3 /error/include/error.h
parent2f8ff39a8d95b95288875d92abb74b1428713906 (diff)
Add error library.
Diffstat (limited to 'error/include/error.h')
-rw-r--r--error/include/error.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/error/include/error.h b/error/include/error.h
new file mode 100644
index 0000000..92c06ff
--- /dev/null
+++ b/error/include/error.h
@@ -0,0 +1,22 @@
1#pragma once
2
3#include <cstring.h>
4#include <stdio.h>
5
6/// Get the last error.
7const char* get_error(void);
8
9extern xlstring gfx_error;
10
11/// Set the last error.
12#define set_error(...) \
13 gfx_error.length = snprintf(gfx_error.str, xlstring_size, __VA_ARGS__)
14
15/// Prepend an error to the last error.
16#define prepend_error(...) \
17 { \
18 xlstring head; \
19 head.length = snprintf(head.str, xlstring_size, __VA_ARGS__); \
20 xlstring_append(&head, xlstring_make(": ")); \
21 gfx_error = xlstring_concat(head, gfx_error); \
22 }