Move the AL error enum out of base_exception

This commit is contained in:
Chris Robinson 2020-12-17 16:46:21 -08:00
parent 4d1ac95ae2
commit 7d2e21334c
5 changed files with 14 additions and 8 deletions

View File

@ -72,7 +72,7 @@ const EffectList gEffectList[16]{
bool DisabledEffects[MAX_EFFECTS];
effect_exception::effect_exception(ALenum code, const char *msg, ...) : base_exception{code}
effect_exception::effect_exception(ALenum code, const char *msg, ...) : mErrorCode{code}
{
std::va_list args;
va_start(args, msg);

View File

@ -9,9 +9,13 @@ union EffectProps;
class effect_exception final : public al::base_exception {
ALenum mErrorCode;
public:
[[gnu::format(printf, 3, 4)]]
effect_exception(ALenum code, const char *msg, ...);
ALenum errorCode() const noexcept { return mErrorCode; }
};

View File

@ -48,15 +48,18 @@
namespace {
class filter_exception final : public al::base_exception {
ALenum mErrorCode;
public:
[[gnu::format(printf, 3, 4)]]
filter_exception(ALenum code, const char *msg, ...) : base_exception{code}
filter_exception(ALenum code, const char *msg, ...) : mErrorCode{code}
{
std::va_list args;
va_start(args, msg);
setMessage(msg, args);
va_end(args);
}
ALenum errorCode() const noexcept { return mErrorCode; }
};
#define FILTER_MIN_GAIN 0.0f

View File

@ -94,15 +94,18 @@ protected:
namespace al {
class backend_exception final : public base_exception {
ALCenum mErrorCode;
public:
[[gnu::format(printf, 3, 4)]]
backend_exception(ALCenum code, const char *msg, ...) : base_exception{code}
backend_exception(ALCenum code, const char *msg, ...) : mErrorCode{code}
{
std::va_list args;
va_start(args, msg);
setMessage(msg, args);
va_end(args);
}
ALCenum errorCode() const noexcept { return mErrorCode; }
};
} // namespace al

View File

@ -6,24 +6,20 @@
#include <string>
#include <utility>
#include "AL/alc.h"
namespace al {
class base_exception : public std::exception {
std::string mMessage;
ALCenum mErrorCode;
protected:
base_exception(ALCenum code) : mErrorCode{code} { }
base_exception() = default;
virtual ~base_exception();
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; }
};
} // namespace al