EventNotSubscribedException.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-04
  6. * Changed: 2023-02-23
  7. *
  8. * */
  9. #include <ls-std/core/exception/EventNotSubscribedException.hpp>
  10. #include <ls-std/core/exception/ExceptionMessage.hpp>
  11. using ls::std::core::EventNotSubscribedException;
  12. using ls::std::core::Exception;
  13. using std::move;
  14. using std::string;
  15. EventNotSubscribedException::EventNotSubscribedException() : Exception("EventNotSubscribedException")
  16. {}
  17. EventNotSubscribedException::EventNotSubscribedException(string _message) : EventNotSubscribedException()
  18. {
  19. this->message = ::move(_message);
  20. }
  21. EventNotSubscribedException::~EventNotSubscribedException() noexcept = default;
  22. const char *EventNotSubscribedException::what() const noexcept
  23. {
  24. string concatenatedMessage = this->name + " thrown - ";
  25. if (this->message.empty())
  26. {
  27. concatenatedMessage = concatenatedMessage + "event was not subscribed!";
  28. }
  29. else
  30. {
  31. concatenatedMessage = concatenatedMessage + this->message;
  32. }
  33. return ExceptionMessage{concatenatedMessage}.toCharacterPointer();
  34. }