reorganize directories
[awesomized/libmemcached] / include / libmemcached-1.0 / exception.hpp
diff --git a/include/libmemcached-1.0/exception.hpp b/include/libmemcached-1.0/exception.hpp
new file mode 100644 (file)
index 0000000..4759072
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Summary: Exceptions for the C++ interface
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ */
+
+/**
+ * @file
+ * @brief Exception declarations
+ */
+
+#pragma once
+
+#include <stdexcept>
+#include <string>
+
+namespace memcache 
+{
+  class Exception : public std::runtime_error
+  {
+  public:
+    Exception(const std::string& msg, int in_errno)
+      : 
+        std::runtime_error(msg), 
+        _errno(in_errno) 
+    {}
+
+    Exception(const char *msg, int in_errno)
+      : 
+        std::runtime_error(std::string(msg)), 
+        _errno(in_errno) {}
+
+    virtual ~Exception() throw() {}
+
+    int getErrno() const 
+    { 
+      return _errno; 
+    }
+
+  private:
+    int _errno;
+  };
+
+  class Warning : public Exception
+  {
+  public:
+    Warning(const std::string& msg, int in_errno) : Exception(msg, in_errno) {}
+    Warning(const char *msg, int in_errno) : Exception(msg, in_errno) {}
+  };
+
+  class Error : public Exception
+  {
+  public:
+    Error(const std::string& msg, int in_errno) : Exception(msg, in_errno) {}
+    Error(const char *msg, int in_errno) : Exception(msg, in_errno) {}
+    virtual ~Error() throw() {}
+  };
+
+} /* namespace libmemcached */