First pass on sync with gearman yatl.
[awesomized/libmemcached] / libtest / fatal.hpp
index 6ac62b775f84b224ce0673cea507b2e8a3f43f3f..8b810e7bb44189106ed4c4658bbfafaf830ab557 100644 (file)
 
 #include <stdexcept>
 
-#ifndef __PRETTY_FUNCTION__
-#define __PRETTY_FUNCTION__ __func__
-#endif
-
-#define YATL_STRINGIFY(x) #x
-#define YATL_TOSTRING(x) YATL_STRINGIFY(x)
-#define YATL_AT __FILE__ ":" YATL_TOSTRING(__LINE__)
-#define YATL_AT_PARAM __func__, AT
-#define YATL_UNIQUE __FILE__ ":" YATL_TOSTRING(__LINE__) "_unique"
-#define YATL_UNIQUE_FUNC_NAME __FILE__ ":" YATL_TOSTRING(__LINE__) "_unique_func"
-
-#define LIBYATL_DEFAULT_PARAM __FILE__, __LINE__, __PRETTY_FUNCTION__
-
 namespace libtest {
 
-class exception : public std::runtime_error
+class disconnected : std::runtime_error
 {
 public:
-  exception(const char *, int, const char *);
-
-  int line() const
-  {
-    return _line;
-  }
-
-  const char*  file() const
-  {
-    return _file;
-  }
-
-  const char* func() const
-  {
-    return _func;
-  }
-
-  const char* mesg() const throw()
-  {
-    return _error_message;
-  }
-
-
-protected:
-  char _error_message[BUFSIZ];
-
-private:
-  const char*  _file;
-  int _line;
-  const char* _func;
-};
-
-class fatal : public exception
-{
-public:
-  fatal(const char *file, int line, const char *func, const char *format, ...);
+  disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, ...);
 
   const char* what() const throw()
   {
-    return _error_message;
+    return &_error_message[0];
   }
 
   // The following are just for unittesting the exception class
@@ -105,55 +57,28 @@ public:
   static uint32_t disabled_counter();
   static void increment_disabled_counter();
 
-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* what() const throw()
+  int line()
   {
-    return _error_message;
+    return _line;
   }
 
-  // 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()
+  const char* file()
   {
-    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();
+  const char* func()
+  {
+    return _func;
+  }
 
 private:
+  char _error_message[BUFSIZ];
   in_port_t _port;
   char _instance[1024];
+  int _line;
+  const char*  _file;
+  const char* _func;
 };
 
-
 } // namespace libtest
-
-#define fatal_message(__mesg) throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "%s", __mesg)
-#define fatal_assert(__assert) if((__assert)) {} else { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "%s", #__assert); }