exception.h 876 B

1234567891011121314151617181920212223242526272829
  1. #ifndef AFUN_EXCEPTION_H
  2. #define AFUN_EXCEPTION_H
  3. #include "macro.h"
  4. namespace aFuntool {
  5. class FileOpenException : public std::exception {
  6. std::string msg;
  7. public:
  8. explicit FileOpenException(ConstFilePath file) {msg = std::string("File cannot open") + file;}
  9. virtual const char *what() {return "File cannot open";}
  10. };
  11. class RegexException : public std::exception
  12. {
  13. std::string message;
  14. public:
  15. explicit RegexException(const std::string &msg) { this->message = "Regex Error: " + msg;}
  16. virtual const char *what() {return message.c_str();}
  17. };
  18. class LogFatalError : public std::exception {
  19. std::string message;
  20. public:
  21. explicit LogFatalError(const char *msg) {message = msg;}
  22. virtual const char *what() {return message.c_str();}
  23. };
  24. }
  25. #endif //AFUN_EXCEPTION_H