summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/error.h
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
committerpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
commitfcedfddf00b3f994e4f4e40332ac7fc192c63244 (patch)
tree51d38e62c7bdfcc5f9a5e9435fe820c93cfc9a3d /vere/pkg/noun/error.h
claude is gud
Diffstat (limited to 'vere/pkg/noun/error.h')
-rw-r--r--vere/pkg/noun/error.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/vere/pkg/noun/error.h b/vere/pkg/noun/error.h
new file mode 100644
index 0000000..57932bf
--- /dev/null
+++ b/vere/pkg/noun/error.h
@@ -0,0 +1,38 @@
+/// @file
+
+#ifndef U3_ERROR_H
+#define U3_ERROR_H
+
+#include "manage.h"
+
+/* Assert. Good to capture.
+
+ TODO: determine which u3_assert calls can rather call c3_dessert, i.e. in
+ public releases, which calls to u3_assert should abort and which should
+ no-op? If the latter, is the assert useful inter-development to validate
+ conditions we might accidentally break or not useful at all?
+*/
+
+#if defined(ASAN_ENABLED) && defined(__clang__)
+# define u3_assert(x) \
+ do { \
+ if (!(x)) { \
+ u3m_bail(c3__oops); \
+ abort(); \
+ } \
+ } while(0)
+#else
+# define u3_assert(x) \
+ do { \
+ if (!(x)) { \
+ fflush(stderr); \
+ fprintf(stderr, "\rAssertion '%s' " \
+ "failed in %s:%d\r\n", \
+ #x, __FILE__, __LINE__); \
+ u3m_bail(c3__oops); \
+ abort(); \
+ } \
+ } while(0)
+#endif /* if defined(ASAN_ENABLED) && defined(__clang__) */
+
+#endif /* ifndef U3_ERROR_H */