except.h 753 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef CORE_EXCEPT_H
  2. #define CORE_EXCEPT_H
  3. #include <cstdarg>
  4. #include <exception>
  5. #include <string>
  6. #include <utility>
  7. namespace al {
  8. class base_exception : public std::exception {
  9. std::string mMessage;
  10. protected:
  11. auto setMessage(const char *msg, std::va_list args) -> void;
  12. public:
  13. base_exception() = default;
  14. base_exception(const base_exception&) = default;
  15. base_exception(base_exception&&) = default;
  16. ~base_exception() override;
  17. auto operator=(const base_exception&) -> base_exception& = default;
  18. auto operator=(base_exception&&) -> base_exception& = default;
  19. [[nodiscard]] auto what() const noexcept -> const char* override { return mMessage.c_str(); }
  20. };
  21. } // namespace al
  22. #endif /* CORE_EXCEPT_H */