diff options
Diffstat (limited to 'common/alexcpt.h')
-rw-r--r-- | common/alexcpt.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/common/alexcpt.h b/common/alexcpt.h index ff09bab2..b399e8f7 100644 --- a/common/alexcpt.h +++ b/common/alexcpt.h @@ -1,28 +1,26 @@ #ifndef ALEXCPT_H #define ALEXCPT_H +#include <cstdarg> #include <exception> #include <string> +#include <utility> #include "AL/alc.h" -#ifdef __GNUC__ -#define ALEXCPT_FORMAT(x, y, z) __attribute__((format(x, (y), (z)))) -#else -#define ALEXCPT_FORMAT(x, y, z) -#endif - - namespace al { -class backend_exception final : public std::exception { +class base_exception : public std::exception { std::string mMessage; ALCenum mErrorCode; -public: - backend_exception(ALCenum code, const char *msg, ...) ALEXCPT_FORMAT(printf, 3,4); +protected: + base_exception(ALCenum code) : mErrorCode{code} { } + void setMessage(const char *msg, std::va_list args); + +public: const char *what() const noexcept override { return mMessage.c_str(); } ALCenum errorCode() const noexcept { return mErrorCode; } }; |