tool_exception.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef AFUN_TOOL_EXCEPTION_H
  2. #define AFUN_TOOL_EXCEPTION_H
  3. #ifdef __cplusplus
  4. #include "aFunToolExport.h"
  5. #include "tool_macro.h"
  6. #include "tool.h"
  7. #ifndef AFUN_TOOL_C
  8. namespace aFuntool {
  9. #endif
  10. class AFUN_TOOL_EXPORT aFunException : public std::exception {
  11. std::string message;
  12. public:
  13. AFUN_INLINE explicit aFunException(std::string msg);
  14. [[nodiscard]] const char *what() const noexcept override;
  15. [[nodiscard]] AFUN_INLINE const std::string &getMessage() const;
  16. };
  17. class aFuntoolException : public aFunException {
  18. public:
  19. AFUN_INLINE explicit aFuntoolException(const std::string &msg);
  20. };
  21. class FileOpenException : public aFuntoolException {
  22. public:
  23. AFUN_INLINE explicit FileOpenException(const FilePath &file);
  24. };
  25. class RegexException : public aFuntoolException {
  26. public:
  27. AFUN_INLINE explicit RegexException(const std::string &msg);
  28. };
  29. class LogFatalError : public aFuntoolException {
  30. public:
  31. AFUN_INLINE explicit LogFatalError(const char *msg);
  32. };
  33. class Exit : public aFuntoolException {
  34. int exit_code;
  35. public:
  36. AFUN_INLINE explicit Exit(int exit_code_);
  37. AFUN_INLINE int getExitCode() const;
  38. };
  39. #ifndef AFUN_TOOL_C
  40. }
  41. #endif
  42. #include "tool_exception.inline.h"
  43. #endif
  44. #endif //AFUN_TOOL_EXCEPTION_H