summaryrefslogtreecommitdiff
path: root/source/base/base_error.h
diff options
context:
space:
mode:
authornasr <nsrddyn@gmail.com>2026-03-14 21:40:32 +0000
committernasr <nsrddyn@gmail.com>2026-03-14 21:40:32 +0000
commit53cd9c4c3408b5f2e54e891baf471c0d774ea2cd (patch)
tree7fcdfdd25b7e163b40fe3d2961a605b3a2720ba4 /source/base/base_error.h
parente51d57e2da70ea2688a72602aeb5f7c4040e72b7 (diff)
feature(base): ascii colors, error framework ( ai help ). testing idea meta program. refactor
Diffstat (limited to 'source/base/base_error.h')
-rw-r--r--source/base/base_error.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/source/base/base_error.h b/source/base/base_error.h
index e69de29..b2bb4c0 100644
--- a/source/base/base_error.h
+++ b/source/base/base_error.h
@@ -0,0 +1,47 @@
1/* base library internal logging system */
2#ifndef BASE_ERROR_H
3#define BASE_ERROR_H
4
5#define error_at(msg) \
6 do \
7 { \
8 os_write(STDERR_FD, RED "[ERROR] ", LEN(RED "[ERROR] ")); \
9 write_string(STDERR_FD, __FILE__); \
10 write_string(STDERR_FD, ":"); \
11 write_int(__LINE__); \
12 write_string(STDERR_FD, " in "); \
13 write_string(STDERR_FD, __func__); \
14 write_string(STDERR_FD, ": "); \
15 write_string(STDERR_FD, (msg)); \
16 os_write(STDERR_FD, RESET "\n", LEN(RESET "\n")); \
17 } while (0)
18
19#define fatal(msg) \
20 do \
21 { \
22 error_at(msg); \
23 _exit(1); \
24 } while (0)
25
26#define assert_msg(expr, msg) \
27 do \
28 { \
29 if (!(expr)) \
30 { \
31 fatal(msg); \
32 } \
33 } while (0)
34
35#define warn(msg) \
36 do \
37 { \
38 os_write(STDERR_FD, YELLOW "[WARN] ", LEN(YELLOW "[WARN] ")); \
39 write_string(STDERR_FD, __FILE__); \
40 write_string(STDERR_FD, ":"); \
41 write_int(__LINE__); \
42 write_string(STDERR_FD, ": "); \
43 write_string(STDERR_FD, (msg)); \
44 os_write(STDERR_FD, RESET "\n", LEN(RESET "\n")); \
45 } while (0)
46
47#endif /* BASE_ERROR_H */