errors.hpp 553 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef _FY_ERRORS_HPP_
  2. #define _FY_ERRORS_HPP_
  3. #include <string>
  4. namespace base {
  5. class error {
  6. public:
  7. error(const std::string& what):what_(what.c_str()) {
  8. }
  9. std::string what() const {
  10. return what_;
  11. }
  12. bool operator!=(const error& e) const {
  13. return e.what_.compare(what_) != 0;
  14. }
  15. bool operator==(const error& e) const {
  16. return e.what_.compare(what_) == 0;
  17. }
  18. private:
  19. std::string what_;
  20. };
  21. } /* namespace fy */
  22. #define nil base::error("nil")
  23. #define error_timeout base::error("timeout")
  24. #endif /* _FY_ERRORS_HPP_ */