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#ifndef LIBMEMACHED_EXCEPTION_HPP 14#define LIBMEMACHED_EXCEPTION_HPP 15 16#include <stdexcept> 17#include <string> 18 19namespace memcache 20{ 21 class Exception : public std::runtime_error 22 { 23 public: 24 Exception(const std::string& msg, int in_errno) 25 : 26 std::runtime_error(msg), 27 _errno(in_errno) 28 {} 29 30 Exception(const char *msg, int in_errno) 31 : 32 std::runtime_error(std::string(msg)), 33 _errno(in_errno) {} 34 35 virtual ~Exception() throw() {} 36 37 int getErrno() const 38 { 39 return _errno; 40 } 41 42 private: 43 int _errno; 44 }; 45 46 class Warning : public Exception 47 { 48 public: 49 Warning(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} 50 Warning(const char *msg, int in_errno) : Exception(msg, in_errno) {} 51 }; 52 53 class Error : public Exception 54 { 55 public: 56 Error(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} 57 Error(const char *msg, int in_errno) : Exception(msg, in_errno) {} 58 virtual ~Error() throw() {} 59 }; 60 61} /* namespace libmemcached */ 62 63#endif /* LIBMEMACHED_EXCEPTION_HPP */ 64