summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'error.c')
-rw-r--r--error.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/error.c b/error.c
new file mode 100644
index 0000000..2d69457
--- /dev/null
+++ b/error.c
@@ -0,0 +1,29 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+
+#include "apl9.h"
+
+ErrorHandler globalerror;
+
+Rune *errorstrs[] = {
+ [ESyntax] = L"SYNTAX ERROR",
+ [EParse] = L"PARSE ERROR",
+ [EValue] = L"VALUE ERROR",
+ [EDomain] = L"DOMAIN ERROR",
+ [ERank] = L"RANK ERROR",
+ [EType] = L"TYPE ERROR",
+ [ELength] = L"LENGTH ERROR",
+ [EIndex] = L"INDEX ERROR",
+ [EShape] = L"SHAPE ERROR",
+ [ENotImplemented] = L"NOT IMPLEMENTED",
+};
+
+void
+throwerror(Rune *msg, int err)
+{
+ free(globalerror.msg);
+ globalerror.msg = msg ? runestrdup(msg) : nil;
+ longjmp(globalerror.jmp, err);
+}
+