Exception.h 606 B

123456789101112131415161718192021222324252627282930
  1. #ifndef IM_EXCEPTIONS_H
  2. #define IM_EXCEPTIONS_H
  3. #include <string>
  4. #include <exception>
  5. class Exception: public std::exception
  6. {
  7. protected:
  8. std::string where;
  9. std::string msg;
  10. mutable std::string fullMessage;
  11. public:
  12. Exception(): where("unknown"), msg("unknown") {}
  13. Exception(const std::string& where, const std::string& msg):
  14. where(where), msg(msg) {}
  15. virtual void setWhere(const std::string& w)
  16. {
  17. where = w;
  18. }
  19. virtual const char* what() const noexcept
  20. {
  21. fullMessage = where + " - " + msg;
  22. return fullMessage.c_str();
  23. }
  24. virtual ~Exception() throw() {}
  25. };
  26. #endif