aboutsummaryrefslogtreecommitdiff
path: root/Exception.cpp
blob: 5cb70941be2dcf2c9805d1505f7fc07d5f62b148 (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
50
51
52
#include <cstdarg>
#include <cstdio>
#include <cstdlib>

#include "Exception.h"

Exception::~Exception() {
	if (error != NULL)
		free(error);
}

const char * Exception::what() {
	return error;
}

void Exception::va_format(va_list args, const char * fmt) {
	va_list args_copy;
	va_copy(args_copy, args);

	size_t sz = vsnprintf(NULL, 0, fmt, args_copy) + 1;
	if (error != NULL) free(error);
	error = (char *) malloc(sz);
	va_end(args_copy);

	vsnprintf(error, sz, fmt, args);
}

Exception::Exception(const char * fmt, ...) {
	va_list args;
	va_start(args, fmt);
	va_format(args, fmt);
	va_end(args);
}
CircuitException::CircuitException(const char * fmt, ...) {
	va_list args;
	va_start(args, fmt);
	va_format(args, fmt);
	va_end(args);
}
ParserException::ParserException(const char * fmt, ...) {
	va_list args;
	va_start(args, fmt);
	va_format(args, fmt);
	va_end(args);
}
NodeException::NodeException(Node * node, const char * fmt, ...) {
	this->node = node;
	va_list args;
	va_start(args, fmt);
	va_format(args, fmt);
	va_end(args);
}