diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 20:01:27 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 20:01:27 +0100 |
commit | 9283e1eb66d6ff96b02f317e28cb6ff060953cdf (patch) | |
tree | c03d853ef620216f1c2299936004f56c6c3cee04 /frontend/Exception.cpp | |
parent | 7285f9f2c2622acff734e31314f92df9b25cae16 (diff) |
WIP load XML
Diffstat (limited to 'frontend/Exception.cpp')
-rw-r--r-- | frontend/Exception.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/frontend/Exception.cpp b/frontend/Exception.cpp new file mode 100644 index 0000000..423f4e9 --- /dev/null +++ b/frontend/Exception.cpp @@ -0,0 +1,30 @@ +#include <cstdarg> +#include <cstdio> +#include <cstdlib> + +#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<char>(static_cast<char *>(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); +} + |