summaryrefslogtreecommitdiff
path: root/error.c
blob: 626c793092f9a4bed7ac4692bdb27683dd158fed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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);
}