Don't rely on terminate in a catch block giving a useful message
[openal-soft.git] / core / except.h
blob1b3d634fc58fab4ca3bbe1938295062a55e55dbf
1 #ifndef CORE_EXCEPT_H
2 #define CORE_EXCEPT_H
4 #include <cstdarg>
5 #include <exception>
6 #include <string>
7 #include <utility>
10 namespace al {
12 class base_exception : public std::exception {
13 std::string mMessage;
15 protected:
16 auto setMessage(const char *msg, std::va_list args) -> void;
18 public:
19 base_exception() = default;
20 base_exception(const base_exception&) = default;
21 base_exception(base_exception&&) = default;
22 ~base_exception() override;
24 auto operator=(const base_exception&) -> base_exception& = default;
25 auto operator=(base_exception&&) -> base_exception& = default;
27 [[nodiscard]] auto what() const noexcept -> const char* override { return mMessage.c_str(); }
30 } // namespace al
32 #endif /* CORE_EXCEPT_H */