Let tests pass for the moment.
[awesomized/libmemcached] / libtest / fatal.hpp
index bb8cc938364b95076a3ed2ca038d43d65a4dbd21..6ac62b775f84b224ce0673cea507b2e8a3f43f3f 100644 (file)
 
 namespace libtest {
 
-class fatal : std::runtime_error
+class exception : public std::runtime_error
 {
 public:
-  fatal(const char *file, int line, const char *func, const char *format, ...);
+  exception(const char *, int, const char *);
 
-  const char* what() const throw()
+  int line() const
   {
-    return _error_message;
+    return _line;
   }
 
-  const char* mesg() const throw()
+  const char*  file() const
   {
-    return _error_message;
+    return _file;
   }
 
-  // The following are just for unittesting the exception class
-  static bool is_disabled();
-  static void disable();
-  static void enable();
-  static uint32_t disabled_counter();
-  static void increment_disabled_counter();
-
-  int line()
+  const char* func() const
   {
-    return _line;
+    return _func;
   }
 
-  const char*  file()
+  const char* mesg() const throw()
   {
-    return _file;
+    return _error_message;
   }
 
-  const char* func()
-  {
-    return _func;
-  }
 
-private:
+protected:
   char _error_message[BUFSIZ];
-  char _mesg[BUFSIZ];
-  int _line;
+
+private:
   const char*  _file;
+  int _line;
   const char* _func;
 };
 
-class disconnected : std::runtime_error
+class fatal : public exception
 {
 public:
-  disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, const char *format, ...);
+  fatal(const char *file, int line, const char *func, const char *format, ...);
 
   const char* what() const throw()
   {
@@ -115,28 +105,51 @@ public:
   static uint32_t disabled_counter();
   static void increment_disabled_counter();
 
-  int line()
-  {
-    return _line;
-  }
+private:
+};
+
+class disconnected : public exception
+{
+public:
+  disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, const char *format, ...);
 
-  const char* file()
+  const char* what() const throw()
   {
-    return _file;
+    return _error_message;
   }
 
-  const char* func()
+  // The following are just for unittesting the exception class
+  static bool is_disabled();
+  static void disable();
+  static void enable();
+  static uint32_t disabled_counter();
+  static void increment_disabled_counter();
+
+private:
+  in_port_t _port;
+  char _instance[1024];
+};
+
+class start : public exception
+{
+public:
+  start(const char *file, int line, const char *func, const std::string&, const in_port_t port, const char *format, ...);
+
+  const char* what() const throw()
   {
-    return _func;
+    return _error_message;
   }
 
+  // The following are just for unittesting the exception class
+  static bool is_disabled();
+  static void disable();
+  static void enable();
+  static uint32_t disabled_counter();
+  static void increment_disabled_counter();
+
 private:
-  char _error_message[BUFSIZ];
   in_port_t _port;
   char _instance[1024];
-  int _line;
-  const char*  _file;
-  const char* _func;
 };