X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ffatal.hpp;h=7e627a46bee54b95787af6df8e1ed08df3961bb3;hb=20ac79fc8f8999f39b4fb33e55d4a205ce0c9a10;hp=54f672b652a8808973de15800def96a430e8d009;hpb=bce9a74e8addd1085b2e751508bf9ab0c2e84e45;p=awesomized%2Flibmemcached diff --git a/libtest/fatal.hpp b/libtest/fatal.hpp index 54f672b6..7e627a46 100644 --- a/libtest/fatal.hpp +++ b/libtest/fatal.hpp @@ -38,33 +38,22 @@ #include -#ifndef __PRETTY_FUNCTION__ -#define __PRETTY_FUNCTION__ __func__ -#endif - -#define LIBYATL_DEFAULT_PARAM __FILE__, __LINE__, __PRETTY_FUNCTION__ - namespace libtest { -class fatal : std::runtime_error +class disconnected : std::runtime_error { 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; - } - - const char* mesg() const throw() - { - return _error_message; + return &_error_message[0]; } // 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(); @@ -73,7 +62,7 @@ public: return _line; } - const char* file() + const char* file() { return _file; } @@ -85,37 +74,11 @@ public: private: char _error_message[BUFSIZ]; - char _mesg[BUFSIZ]; + in_port_t _port; + char _instance[1024]; int _line; const char* _file; const char* _func; }; -class disconnected : std::runtime_error -{ -public: - disconnected(const char *file, int line, const char *func, const char *instance, const in_port_t port, const char *format, ...); - - const char* what() const throw() - { - 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]; -}; - - } // 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); }