blob: c6dd60b1cd51c287ac0273a23107e234a9e10971 (
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
|
#include "Exception.h"
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
Exception::Exception(const char * fmt, ...) {
va_list args;
va_start(args, fmt);
size_t sz = vsnprintf(NULL, 0, fmt, args) + 1;
if (error != NULL) free(error);
error = (char *) malloc(sz);
vsnprintf(error, sz, fmt, args);
va_end(args);
}
Exception::~Exception() {
if (error != NULL)
free(error);
}
const char * Exception::what() {
return error;
}
|