Merge in namespace fixes for binary protocol.
[awesomized/libmemcached] / libmemcached / exception.hpp
index 8fb952e15f6a1577320c8ed724d0b1c84529544d..4759072abdd758445e47674f37ef52cd9f151835 100644 (file)
@@ -1,11 +1,8 @@
 /*
- * Drizzle Client & Protocol Library
+ * Summary: Exceptions for the C++ interface
  *
- * Copyright (C) 2009 Patrick Galbraith (patg@patg.net)
- * All rights reserved.
+ * Copy: See Copyright for the status of this software.
  *
- * Use and distribution licensed under the BSD license.  See
- * the COPYING file in this directory for full text.
  */
 
 /**
  * @brief Exception declarations
  */
 
-#ifndef LIBMEMACHED_EXCEPTION_HPP
-#define LIBMEMACHED_EXCEPTION_HPP
+#pragma once
 
 #include <stdexcept>
+#include <string>
 
-
-namespace memcache {
-
+namespace memcache 
+{
   class Exception : public std::runtime_error
   {
   public:
-    Exception(const std::string& msg, bool errno)
-      : std::runtime_error(msg), _errno(errno) {}
-    Exception(const char *msg, bool errno)
-      : std::runtime_error(msg), _errno(errno) {}
+    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; }
+    int getErrno() const 
+    { 
+      return _errno; 
+    }
+
   private:
     int _errno;
-
   };
 
   class Warning : public Exception
   {
   public:
-    Warning(const std::string& msg, bool errno) : Exception(msg, errno) {}
-    Warning(const char *msg, bool errno) : Exception(msg, errno) {}
+    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, bool errno) : Exception(msg, errno) {}
-    Error(const char *msg, bool errno) : Exception(msg, errno) {}
+    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 */
-
-#endif /* LIBMEMACHED_EXCEPTION_HPP */