except.h 564 B

12345678910111213141516171819202122232425262728293031
  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. base_exception() = default;
  12. virtual ~base_exception();
  13. void setMessage(const char *msg, std::va_list args);
  14. public:
  15. const char *what() const noexcept override { return mMessage.c_str(); }
  16. };
  17. } // namespace al
  18. #define START_API_FUNC try
  19. #define END_API_FUNC catch(...) { std::terminate(); }
  20. #endif /* CORE_EXCEPT_H */