33 #ifndef EPICSEXCEPTION_H_ 34 #define EPICSEXCEPTION_H_ 44 # define EXCEPT_DEPTH 20
47 #if defined(__GLIBC__
) || (defined(__APPLE__) && defined(__MACH__)) 48 # include <execinfo.h> 50 # define EXCEPT_USE_BACKTRACE 51 #elif defined(_WIN32) && !defined(_MINGW) && !defined(SKIP_DBGHELP) 55 # define EXCEPT_USE_CAPTURE 57 # define EXCEPT_USE_NONE 60 #if defined(_WIN32) && !defined(_MINGW) 61 #pragma warning( push ) 62 #pragma warning(disable: 4275
) 63 #pragma warning(disable: 4251
) 66 namespace epics {
namespace pvData {
75 #ifndef EXCEPT_USE_NONE 84 #if defined(EXCEPT_USE_BACKTRACE
) 88 #elif defined(EXCEPT_USE_CAPTURE) 101 #ifndef THROW_EXCEPTION_COMPAT 114 ExceptionMixed(
const E& self,
const char* file,
int line)
115 :E(self), ExceptionMixin(file,line)
118 ExceptionMixed(
const char* file,
int line)
119 :E(), ExceptionMixin(file,line)
122 template<
typename A1>
123 ExceptionMixed(A1 arg1,
const char* file,
int line)
124 :E(arg1), ExceptionMixin(file,line)
127 template<
typename A1,
typename A2>
128 ExceptionMixed(A1 arg1, A2 arg2,
const char* file,
int line)
129 :E(arg1,arg2), ExceptionMixin(file,line)
137 makeException(
const E& self,
const char* file,
int line)
145 showException(
const E& ex)
147 const ExceptionMixin *mx=
dynamic_cast<
const ExceptionMixin*>(&ex);
148 if(!mx)
return std::string();
155 #define THROW_EXCEPTION(E) do 157 throw ::epics::pvData::detail::makeException(E, __FILE__, __LINE__); \ 161 #define THROW_EXCEPTION1(TYPE) do 163 throw ::epics::pvData::detail::ExceptionMixed<TYPE>(__FILE__, __LINE__); 167 #define THROW_EXCEPTION2(TYPE,MSG) do 169 throw ::epics::pvData::detail::ExceptionMixed<TYPE>(MSG, __FILE__, __LINE__); \ 172 #define PRINT_EXCEPTION2(EI, FP) do 174 ::epics::pvData::ExceptionMixin *_em_p=dynamic_cast< ::epics::pvData::ExceptionMixin*>(&EI); 175 if (_em_p) {_em_p->print(FP);} \ 180 #if !defined(__GNUC__
) || __GNUC__
< 4
181 # define SHOW_EXCEPTION(EI) ::epics::pvData::detail::showException(EI) 183 # define SHOW_EXCEPTION(EI) 184 ({ ::epics::pvData::ExceptionMixin *_mx=dynamic_cast< ::epics::pvData::ExceptionMixin*>(&(EI)); 185 _mx ? _mx->show() : std::string(); 192 #define PRINT_EXCEPTION(EI) do{}while(0
) 193 #define PRINT_EXCEPTION2(EI,FP) do{}while(0
) 194 #define SHOW_EXCEPTION(EI) std::string() 196 #define THROW_EXCEPTION(E) do{throw (E);}while(0
) 197 #define THROW_EXCEPTION1(E) do{throw (E)();}while(0
) 198 #define THROW_EXCEPTION2(E,A) do{throw (E)(A);}while(0
) 221 virtual const char*
what()
const throw();
227 #if defined(_WIN32) && !defined(_MINGW) 228 #pragma warning( pop ) 231 #define THROW_BASE_EXCEPTION(msg) THROW_EXCEPTION2(::epics::pvData::BaseException, msg) Base for pvData exceptions.
virtual void serialize(ByteBuffer *buffer, SerializableControl *flusher, std::size_t offset, std::size_t count) const =0
#define THROW_EXCEPTION2(TYPE, MSG)
#define PRINT_EXCEPTION2(EI, FP)