diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/CMakeLists.txt | 1 | ||||
-rw-r--r-- | backend/Exception.cpp | 22 | ||||
-rw-r--r-- | backend/Exception.h | 14 |
3 files changed, 37 insertions, 0 deletions
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index e0c377b..b7e8996 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -15,5 +15,6 @@ target_sources(main PUBLIC String.cpp print.cpp Player.cpp + Exception.cpp ) diff --git a/backend/Exception.cpp b/backend/Exception.cpp new file mode 100644 index 0000000..4044d6a --- /dev/null +++ b/backend/Exception.cpp @@ -0,0 +1,22 @@ +#include <cstdarg> +#include <cstdio> +#include <cstdlib> +#include <cstring> + +#include "backend/String.h" + +#include "Exception.h" + +using namespace std; + +const char * Exception::what() { + return this->error.c_str(); +} + +Exception::Exception(const char * fmt, ...) { + va_list args; + va_start(args, fmt); + this->error = String::va_fmt(args, fmt); + va_end(args); +} + diff --git a/backend/Exception.h b/backend/Exception.h new file mode 100644 index 0000000..bc65aa0 --- /dev/null +++ b/backend/Exception.h @@ -0,0 +1,14 @@ +#pragma once + +#include "backend/String.h" + +class Exception { +public: + Exception(const char * fmt, ...); + const char * what(); + +protected: + Exception() = default; + String error; +}; + |