aboutsummaryrefslogtreecommitdiffstats
path: root/common/alexcpt.h
blob: 5b33f0925b506c4821bd5aba9639af54b04925e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef ALEXCPT_H
#define ALEXCPT_H

#include <cstdarg>
#include <exception>
#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} { }
    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

#define START_API_FUNC try

#define END_API_FUNC catch(...) { std::terminate(); }

#endif /* ALEXCPT_H */