1 /* 2 * Summary: Exceptions for the C++ interface 3 * 4 * Copy: See Copyright for the status of this software. 5 * 6 */ 7 8 /** 9 * @file 10 * @brief Exception declarations 11 */ 12 13 #pragma once 14 15 #include <stdexcept> 16 #include <string> 17 18 namespace memcache 19 { 20 class Exception : public std::runtime_error 21 { 22 public: Exception(const std::string & msg,int in_errno)23 Exception(const std::string& msg, int in_errno) 24 : 25 std::runtime_error(msg), 26 _errno(in_errno) 27 {} 28 Exception(const char * msg,int in_errno)29 Exception(const char *msg, int in_errno) 30 : 31 std::runtime_error(std::string(msg)), 32 _errno(in_errno) {} 33 ~Exception()34 virtual ~Exception() throw() {} 35 getErrno() const36 int getErrno() const 37 { 38 return _errno; 39 } 40 41 private: 42 int _errno; 43 }; 44 45 class Warning : public Exception 46 { 47 public: Warning(const std::string & msg,int in_errno)48 Warning(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} Warning(const char * msg,int in_errno)49 Warning(const char *msg, int in_errno) : Exception(msg, in_errno) {} 50 }; 51 52 class Error : public Exception 53 { 54 public: Error(const std::string & msg,int in_errno)55 Error(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} Error(const char * msg,int in_errno)56 Error(const char *msg, int in_errno) : Exception(msg, in_errno) {} ~Error()57 virtual ~Error() throw() {} 58 }; 59 60 } /* namespace libmemcached */ 61