IllegalArithmeticOperationException.cpp 1.2 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/ExceptionMessage.hpp>
  10. #include <ls-std/core/exception/IllegalArithmeticOperationException.hpp>
  11. using ls::std::core::Exception;
  12. using ls::std::core::IllegalArithmeticOperationException;
  13. using std::move;
  14. using std::string;
  15. IllegalArithmeticOperationException::IllegalArithmeticOperationException() : Exception("IllegalArithmeticOperationException")
  16. {}
  17. IllegalArithmeticOperationException::IllegalArithmeticOperationException(string _message) : IllegalArithmeticOperationException()
  18. {
  19. this->message = ::move(_message);
  20. }
  21. IllegalArithmeticOperationException::~IllegalArithmeticOperationException() noexcept = default;
  22. const char *IllegalArithmeticOperationException::what() const noexcept
  23. {
  24. string concatenatedMessage = this->name + " thrown - ";
  25. if (this->message.empty())
  26. {
  27. concatenatedMessage = concatenatedMessage + "arithmetic operation is not allowed!";
  28. }
  29. else
  30. {
  31. concatenatedMessage = concatenatedMessage + this->message;
  32. }
  33. return ExceptionMessage{concatenatedMessage}.toCharacterPointer();
  34. }