diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-12 14:01:17 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-12 14:01:17 +0200 |
commit | efa2f195a5f9c356318fb50532168fa2ee4c0979 (patch) | |
tree | f0e78786cd5b71ff0e389b7842f2a88f4b4f7358 /Exception.cpp | |
parent | 72c9b98b074d98d60983b178b06e1872eb96c242 (diff) | |
parent | a7eb10e81568b65c39d6e1d042309916a9180a2b (diff) |
Merge branch 'master' of github.com:lonkaars/depa
Diffstat (limited to 'Exception.cpp')
-rw-r--r-- | Exception.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Exception.cpp b/Exception.cpp new file mode 100644 index 0000000..52e30dc --- /dev/null +++ b/Exception.cpp @@ -0,0 +1,23 @@ +#include "Exception.h" + +#include <cstdarg> +#include <cstdio> + +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; +}
\ No newline at end of file |