summaryrefslogtreecommitdiff
path: root/src/error.cpp
blob: bdf4080ec3904a4aa1843a958c551de06569dc24 (plain)
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
#include <stdio.h>
#include <stdarg.h>

#include "rwbase.h"
#include "rwerror.h"

namespace rw {

static Error error;

void
setError(Error *e)
{
	error = *e;
}

Error*
getError(Error *e)
{
	*e = error;
	error.plugin = 0;
	error.code = 0;
	return e;
}

#define ECODE(c, s) s

const char *errstrs[] = {
	"No error",
#include "base.err"
};

#undef ECODE

char*
dbgsprint(uint32 code, ...)
{
	va_list ap;
	static char strbuf[512];

	if(code & 0x80000000)
		code &= ~0x80000000;
	va_start(ap, code);
	vsprintf(strbuf, errstrs[code], ap);
	va_end(ap);
	return strbuf;
}

}