aboutsummaryrefslogtreecommitdiffstats
path: root/core/except.h
blob: 90e3346e4d4aaaedc9b0be47dfbe486a0a0ed809 (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
#ifndef CORE_EXCEPT_H
#define CORE_EXCEPT_H

#include <cstdarg>
#include <exception>
#include <string>
#include <utility>


namespace al {

class base_exception : public std::exception {
    std::string mMessage;

protected:
    base_exception() = default;

    auto setMessage(const char *msg, std::va_list args) -> void;

public:
    ~base_exception() override;

    [[nodiscard]] auto what() const noexcept -> const char* override { return mMessage.c_str(); }
};

} // namespace al

#define START_API_FUNC try

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

#endif /* CORE_EXCEPT_H */