Exception.hpp 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-22
  6. * Changed: 2024-09-11
  7. *
  8. * */
  9. #ifndef LS_STD_EXCEPTION_HPP
  10. #define LS_STD_EXCEPTION_HPP
  11. #include <exception>
  12. #include <ls-std/os/dynamic-goal.hpp>
  13. #include <string>
  14. #include <string_view>
  15. /*
  16. * @doc: class(name: 'Exception', package: 'core')
  17. * @doc: core.Exception.description('This a base exception that can be thrown in any scenario.')
  18. * */
  19. namespace ls::std::core
  20. {
  21. class LS_STD_DYNAMIC_GOAL Exception : public ::std::exception
  22. {
  23. public:
  24. explicit Exception(::std::string _name);
  25. ~Exception() noexcept override = 0;
  26. [[nodiscard]] ::std::string getName() const;
  27. protected:
  28. [[nodiscard]] const char *_getIdentifiedMessage(const ::std::string &_defaultMessage) const;
  29. void _setMessage(::std::string_view _message);
  30. private:
  31. ::std::string message{};
  32. ::std::string name{};
  33. };
  34. }
  35. #endif