You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.3 KiB

  1. //
  2. // Created by zhaohe on 19-5-21.
  3. //
  4. #pragma once
  5. #include <fstream>
  6. #include <iostream>
  7. #include <list>
  8. #include <map>
  9. #include <memory>
  10. #include <set>
  11. #include <sstream>
  12. #include <string>
  13. #include <thread>
  14. #include <vector>
  15. // #include <zwtimecpp/core/base/interlog/simple_logger.hpp>
  16. // #include "zwtimecpp/core/base/object.hpp"
  17. namespace iflytop {
  18. namespace core {
  19. using namespace std;
  20. /**
  21. * 1. (ok)
  22. * 2. 使 ( )
  23. * 3.
  24. * 4.
  25. * 5. 线
  26. */
  27. class zexception : public std::exception {
  28. protected:
  29. string stackInfo;
  30. string description;
  31. pthread_t pthreadId;
  32. bool loseInfo = false; // 这个
  33. string stdExceptionWhat;
  34. string stdExceptionTypeinfo;
  35. protected:
  36. mutable bool hasCalledToString = false;
  37. public: // Getter
  38. virtual const string &getStackInfo() const { return stackInfo; }
  39. virtual const string &getDescription() const { return description; }
  40. bool isHasCalledToString() const;
  41. virtual pthread_t getPthreadId() const { return pthreadId; }
  42. virtual bool isLoseInfo() const { return loseInfo; }
  43. virtual void setLoseInfo(bool loseInfo) { zexception::loseInfo = loseInfo; }
  44. const char *what() const _GLIBCXX_USE_NOEXCEPT override;
  45. public:
  46. /**
  47. * ,
  48. *
  49. * : toString, toString, ,
  50. * BaseException的异常会被忽悠掉
  51. * @param description
  52. */
  53. zexception(string description, string stdExceptionTypeinfo = "", string baseExceptionWhat = "");
  54. zexception(string description, const std::exception &stdexcep);
  55. virtual ~zexception();
  56. virtual string toString() const;
  57. /**
  58. * ,1024
  59. * @param fmt
  60. * @param ...
  61. * @return
  62. */
  63. static string format1024(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
  64. static void setLastException(shared_ptr<zexception> e);
  65. static shared_ptr<zexception> getUnHandledException();
  66. private:
  67. void initialize(string description, string stdExceptionTypeinfo = "", string baseExceptionWhat = "");
  68. };
  69. } // namespace core
  70. } // namespace iflytop