FileNotFoundException.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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-07
  7. *
  8. * */
  9. #include <ls-std/core/exception/FileNotFoundException.hpp>
  10. #include <utility>
  11. ls::std::core::FileNotFoundException::FileNotFoundException() = default;
  12. ls::std::core::FileNotFoundException::FileNotFoundException(::std::string _message) : message(::std::move(_message))
  13. {}
  14. ls::std::core::FileNotFoundException::~FileNotFoundException() = default;
  15. const char *ls::std::core::FileNotFoundException::what() const noexcept
  16. {
  17. ::std::string concatenatedMessage = "FileNotFoundException thrown - ";
  18. if (this->message.empty())
  19. {
  20. concatenatedMessage = concatenatedMessage + "file not found!";
  21. }
  22. else
  23. {
  24. concatenatedMessage = concatenatedMessage + this->message;
  25. }
  26. return ls::std::core::FileNotFoundException::_mapMessageToRawPointer(concatenatedMessage);
  27. }
  28. char *ls::std::core::FileNotFoundException::_mapMessageToRawPointer(const ::std::string &_message)
  29. {
  30. char *rawPointerMessage = new char[_message.size() + 1];
  31. strcpy(rawPointerMessage, _message.c_str());
  32. rawPointerMessage[_message.size()] = '\0';
  33. return rawPointerMessage;
  34. }