Exception.cpp 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-22
  6. * Changed: 2023-03-28
  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. Exception::Exception(string _name) : name(::move(_name))
  15. {}
  16. Exception::~Exception() noexcept = default;
  17. string Exception::getName() const
  18. {
  19. return this->name;
  20. }
  21. const char *Exception::_getIdentifiedMessage(const string &_defaultMessage) const
  22. {
  23. string concatenatedMessage = this->name + " thrown - ";
  24. if (this->message.empty())
  25. {
  26. concatenatedMessage = concatenatedMessage + _defaultMessage;
  27. }
  28. else
  29. {
  30. concatenatedMessage = concatenatedMessage + this->message;
  31. }
  32. return ExceptionMessage{concatenatedMessage}.toCharacterPointer();
  33. }