summaryrefslogtreecommitdiff
path: root/error.c
blob: 47837a9afd71443b69758ca445ceb338c23184fc (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
#include <u.h>
#include <libc.h>
#include <thread.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);
}