aboutsummaryrefslogtreecommitdiffstats
path: root/common/alexcpt.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-04-10 15:11:40 -0700
committerChris Robinson <[email protected]>2020-04-10 15:12:57 -0700
commitf7380a44d4c5c6345602db8630ae7bbd971cac1d (patch)
tree9034ad41ed0275498c7c712b9fe4cff8f5c725ee /common/alexcpt.h
parent611a0155cd4bbe588918b07a219cc830c77691c3 (diff)
Use a common base for a couple exceptions
Diffstat (limited to 'common/alexcpt.h')
-rw-r--r--common/alexcpt.h18
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; }
};