summaryrefslogtreecommitdiff
path: root/src/rwerror.h
blob: 2575626f3bdb5f0c852322b4a56843675bf2ff2a (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
namespace rw {

struct Error
{
	uint32 plugin;
	uint32 code;
};

void setError(Error *e);
Error *getError(Error *e);

#define _ERRORCODE(code, ...) code
char *dbgsprint(uint32 code, ...);

/* ecode is supposed to be in format "(errorcode, printf-arguments..)" */
#define RWERROR(ecode) do{          \
	rw::Error _e;                   \
	_e.plugin = PLUGIN_ID;      \
	_e.code = _ERRORCODE ecode; \
	fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
	fprintf(stderr, "%s\n", rw::dbgsprint ecode);       \
	rw::setError(&_e);              \
}while(0)

}