Merge Patrick's exception branch.
[m6w6/libmemcached] / libmemcached / exception.hpp
1 /*
2 * Drizzle Client & Protocol Library
3 *
4 * Copyright (C) 2009 Patrick Galbraith (patg@patg.net)
5 * All rights reserved.
6 *
7 * Use and distribution licensed under the BSD license. See
8 * the COPYING file in this directory for full text.
9 */
10
11 /**
12 * @file
13 * @brief Exception declarations
14 */
15
16 #ifndef LIBMEMACHED_EXCEPTION_HPP
17 #define LIBMEMACHED_EXCEPTION_HPP
18
19 #include <stdexcept>
20
21
22 namespace memcache {
23
24 class Exception : public std::runtime_error
25 {
26 public:
27 Exception(const std::string& msg, bool errno)
28 : std::runtime_error(msg), _errno(errno) {}
29 Exception(const char *msg, bool errno)
30 : std::runtime_error(msg), _errno(errno) {}
31 virtual ~Exception() throw() {}
32
33 int getErrno() const { return _errno; }
34 private:
35 int _errno;
36
37 };
38
39 class Warning : public Exception
40 {
41 public:
42 Warning(const std::string& msg, bool errno) : Exception(msg, errno) {}
43 Warning(const char *msg, bool errno) : Exception(msg, errno) {}
44 };
45
46 class Error : public Exception
47 {
48 public:
49 Error(const std::string& msg, bool errno) : Exception(msg, errno) {}
50 Error(const char *msg, bool errno) : Exception(msg, errno) {}
51 virtual ~Error() throw() {}
52 };
53
54 } /* namespace libmemcached */
55
56 #endif /* LIBMEMACHED_EXCEPTION_HPP */