#include #include #include #include "Exception.h" using namespace std; const char * Exception::what() { return error.get(); } 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; va_end(args_copy); this->error = unique_ptr(static_cast(malloc(sz))); vsnprintf(this->error.get(), sz, fmt, args); } Exception::Exception(const char * fmt, ...) { va_list args; va_start(args, fmt); va_format(args, fmt); va_end(args); }