aboutsummaryrefslogtreecommitdiff
path: root/sys/base/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/base/error.c')
-rw-r--r--sys/base/error.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/sys/base/error.c b/sys/base/error.c
new file mode 100644
index 0000000..dc6421d
--- /dev/null
+++ b/sys/base/error.c
@@ -0,0 +1,57 @@
+#include <u.h>
+#include <base.h>
+
+void
+exits(char *s)
+{
+ if (s == nil || *s == 0)
+ exit(0);
+
+ fputs(s, stderr);
+ exit(1);
+}
+
+void
+errorf(byte* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, args);
+
+ va_end(args);
+}
+
+void
+verrorf(byte* fmt, va_list args)
+{
+ printf("error: ");
+ vprintf(fmt, args);
+ printf("\n");
+}
+
+void
+panicf(byte* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ printf("panic: ");
+ vprintf(fmt, args);
+ printf("\n");
+
+ va_end(args);
+
+ exit(1);
+}
+
+void
+vpanicf(byte* fmt, va_list args)
+{
+ printf("panic: ");
+ vprintf(fmt, args);
+ printf("\n");
+
+ exit(1);
+}