summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'error.c')
-rw-r--r--error.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/error.c b/error.c
new file mode 100644
index 0000000..626c793
--- /dev/null
+++ b/error.c
@@ -0,0 +1,72 @@
+#include <u.h>
+#include <libc.h>
+
+#include "dat.h"
+#include "fns.h"
+
+Term *
+instantiationerror(void)
+{
+ return mkatom(L"instantiation_error");
+}
+
+Term *
+typeerror(Rune *validtype, Term *culprit)
+{
+ Term *valid = mkatom(validtype);
+ valid->next = copyterm(culprit, nil);
+ return mkcompound(L"type_error", 2, valid);
+}
+
+Term *
+domainerror(Rune *validdomain, Term *culprit)
+{
+ Term *valid = mkatom(validdomain);
+ valid->next = copyterm(culprit, nil);
+ return mkcompound(L"domain_error", 2, valid);
+}
+
+Term *
+existenceerror(Rune *objecttype, Term *culprit)
+{
+ Term *obj = mkatom(objecttype);
+ obj->next = copyterm(culprit, nil);
+ return mkcompound(L"existence_error", 2, obj);
+}
+
+Term *
+permissionerror(Rune *operation, Rune *permissiontype, Term *culprit)
+{
+ Term *op = mkatom(operation);
+ op->next = mkatom(permissiontype);
+ op->next->next = copyterm(culprit, nil);
+ return mkcompound(L"permission_error", 3, op);
+}
+
+Term *
+representationerror(Rune *flag)
+{
+ Term *f = mkatom(flag);
+ return mkcompound(L"representation_error", 1, f);
+}
+
+Term *
+evaluationerror(Rune *error)
+{
+ Term *e = mkatom(error);
+ return mkcompound(L"evaluation_error", 1, e);
+}
+
+Term *
+resourceerror(Rune *resource)
+{
+ Term *res = mkatom(resource);
+ return mkcompound(L"resource_error", 1, res);
+}
+
+Term *
+syntaxerror(Rune *error)
+{
+ Term *e = mkatom(error);
+ return mkcompound(L"syntax_error", 1, e);
+} \ No newline at end of file