diff options
Diffstat (limited to 'Exception.cpp')
-rw-r--r-- | Exception.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/Exception.cpp b/Exception.cpp index c6dd60b..371aaa7 100644 --- a/Exception.cpp +++ b/Exception.cpp @@ -4,16 +4,6 @@ #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); @@ -22,3 +12,34 @@ Exception::~Exception() { 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); +} |