2 #ifndef __KITS_EXCEPTION_H 3 #define __KITS_EXCEPTION_H 17 #define EXCEPTION(type) \ 18 type(__FILE__, __LINE__, __PRETTY_FUNCTION__) 19 #define EXCEPTION1(type, arg) \ 20 type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg)) 21 #define EXCEPTION2(type, arg1, arg2) \ 22 type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2)) 27 throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, ""); \ 29 #define THROW1(type, arg) \ 31 fprintf(stderr, arg.c_str()); \ 34 throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, arg.c_str()); \ 37 #define THROW2(type, arg1, arg2) \ 39 fprintf(stderr, arg1, arg2); \ 42 throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2)); \ 46 #define THROW3(type, arg1, arg2, arg3) \ 48 fprintf(stderr, arg1, arg2, arg3); \ 51 throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2, arg3)); \ 54 #define THROW4(type, arg1, arg2, arg3, arg4) \ 56 fprintf(stderr, arg1, arg2, arg3, arg4); \ 59 throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2, arg3, arg4)); \ 63 #define THROW_IF(Exception, err) \ 67 THROW1(Exception, errno_to_str(err)); \ 78 ZappsException(
const char* filename,
int line_num,
const char* function_name,
79 std::string
const& m) : exception() {
81 ss << filename <<
":" << line_num
82 <<
"(" << function_name <<
"): " 87 virtual const char*
what()
const throw() {
88 return _message.data();
94 QPipeException(
const char* filename,
int line_num,
const char* function_name,
95 std::string
const& m) :
ZappsException(filename, line_num, function_name, m) {}
101 std::string
const& m) :
ZappsException(filename, line_num, function_name, m) {}
104 #define DEFINE_EXCEPTION(Name) \ 105 class Name : public ZappsException { \ 107 Name(const char* filename, int line_num, const char* function_name, \ 109 : ZappsException(filename, line_num, function_name, m) \ 115 return strerror(err);
135 #define unreachable() THROW(Unreachable) 138 #endif // __KITS_EXCEPTION_H #define unreachable()
Definition: kits_exception.h:135
std::string _message
Definition: kits_exception.h:75
std::string errno_to_str(int err=errno)
Definition: kits_exception.h:114
Definition: kits_exception.h:71
Definition: kits_exception.h:92
#define ATTRIBUTE(x)
Definition: compat.h:33
ZappsException(const char *filename, int line_num, const char *function_name, std::string const &m)
Definition: kits_exception.h:78
QPipeException(const char *filename, int line_num, const char *function_name, std::string const &m)
Definition: kits_exception.h:94
virtual const char * what() const
Definition: kits_exception.h:87
ThreadException(const char *filename, int line_num, const char *function_name, std::string const &m)
Definition: kits_exception.h:100
Definition: kits_exception.h:98
#define DEFINE_EXCEPTION(Name)
Definition: kits_exception.h:104