Exception.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-22
  6. * Changed: 2024-05-31
  7. *
  8. * */
  9. #include <ls-std/core/exception/Exception.hpp>
  10. #include <ls-std/core/exception/ExceptionMessage.hpp>
  11. using ls::std::core::Exception;
  12. using std::move;
  13. using std::string;
  14. using std::string_view;
  15. Exception::Exception(string _name) : name(::move(_name))
  16. {}
  17. Exception::~Exception() noexcept = default;
  18. string Exception::getName() const
  19. {
  20. return this->name;
  21. }
  22. const char *Exception::_getIdentifiedMessage(const string &_defaultMessage) const
  23. {
  24. string concatenatedMessage = this->name + " thrown - ";
  25. if (this->message.empty())
  26. {
  27. concatenatedMessage = concatenatedMessage + _defaultMessage;
  28. }
  29. else
  30. {
  31. concatenatedMessage = concatenatedMessage + this->message;
  32. }
  33. return ExceptionMessage{concatenatedMessage}.toCharacterPointer();
  34. }
  35. void Exception::_setMessage(const string_view _message)
  36. {
  37. this->message = _message;
  38. }