summaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-01-12 15:50:56 +0100
committerLouis Burda <quent.burda@gmail.com>2023-01-12 15:50:56 +0100
commit099002715d30af646d4582ac2b14322dae3f04d9 (patch)
tree459d79b4e9121e5b6d84eea757cc17400366f075 /src/util.h
parent44070fb5518e2b54748d58da5a5c61f476ef8700 (diff)
downloadtmus-099002715d30af646d4582ac2b14322dae3f04d9.tar.gz
tmus-099002715d30af646d4582ac2b14322dae3f04d9.zip
Refactor error handling
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/util.h b/src/util.h
index 5ae8b74..73cfc10 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdbool.h>
#include <stdio.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
@@ -8,13 +9,23 @@
#define PANIC(...) panic(__FILE__, __LINE__, "" __VA_ARGS__)
#define ASSERT(x) assert((x), __FILE__, __LINE__, #x)
-#define ERROR(...) error("" __VA_ARGS__)
+#define WARNX(...) warn(false, __VA_ARGS__);
+#define WARN(...) warn(true, __VA_ARGS__);
+#define ERRORX(...) error(false, __VA_ARGS__);
+#define ERROR(...) error(true, __VA_ARGS__);
#define UPCAST(iter, type, link) LINK_UPCAST(iter, type, link)
+enum {
+ USER,
+ SYSTEM,
+ INTERNAL
+};
+
void panic(const char *file, int line, const char *msg, ...);
void assert(int cond, const char *file, int line, const char *condstr);
-void error(const char *fmtstr, ...);
+void warn(bool add_error, int type, const char *fmtstr, ...);
+void error(bool add_error, int type, const char *fmtstr, ...);
char *astrdup(const char *str);
char *aprintf(const char *fmtstr, ...);