X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ffatal.hpp;h=c679f9b0844d87961d23728619621ef3bce4d857;hb=d75ea573873b3e4369306a59aa61b776ae9ff53f;hp=bb8cc938364b95076a3ed2ca038d43d65a4dbd21;hpb=3893029e70c654f4fcf3bf8f8ba5b404afc6d446;p=awesomized%2Flibmemcached diff --git a/libtest/fatal.hpp b/libtest/fatal.hpp index bb8cc938..c679f9b0 100644 --- a/libtest/fatal.hpp +++ b/libtest/fatal.hpp @@ -38,75 +38,19 @@ #include -#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 fatal : std::runtime_error +class disconnected : public 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; - } - - // 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() - { - return _line; - } - - const char* file() - { - return _file; - } - - const char* func() - { - return _func; - } - -private: - char _error_message[BUFSIZ]; - char _mesg[BUFSIZ]; - int _line; - const char* _file; - const char* _func; -}; - -class disconnected : std::runtime_error -{ -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() - { - return _error_message; - } + disconnected(const disconnected&); // The following are just for unittesting the exception class static bool is_disabled(); @@ -115,17 +59,17 @@ public: static uint32_t disabled_counter(); static void increment_disabled_counter(); - int line() + int line() const { return _line; } - const char* file() + const char* file() const { return _file; } - const char* func() + const char* func() const { return _func; } @@ -133,14 +77,10 @@ public: private: char _error_message[BUFSIZ]; in_port_t _port; - char _instance[1024]; + char _instance[BUFSIZ]; 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); }