_counter++;
}
+disconnected::disconnected(const char *file, int line, const char *func, const char *instance, const in_port_t port, const char *format, ...) :
+ _port(port),
+ std::runtime_error(func)
+{
+ strncpy(_instance, instance, sizeof(_instance));
+ va_list args;
+ va_start(args, format);
+ char last_error[BUFSIZ];
+ (void)vsnprintf(last_error, sizeof(last_error), format, args);
+ va_end(args);
+
+ snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", file, int(line), last_error, func);
+}
+
} // namespace libtest
char _error_message[BUFSIZ];
};
+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
libtest_libtest_la_SOURCES+= libtest/tmpfile.cc
libtest_libtest_la_SOURCES+= libtest/vchar.cc
-libtest_libtest_la_CXXFLAGS+= ${NO_CONVERSION}
libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST
libtest_libtest_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
libtest_libtest_la_CXXFLAGS+= -DLIBTEST_TEMP="\"tmp_chroot\""
{
std::cerr << e.what() << std::endl;
}
+ catch (libtest::disconnected& e)
+ {
+ std::cerr << "Unhandled disconnection occurred:" << e.what() << std::endl;
+ }
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;