23 #ifndef __ctkException_h
24 #define __ctkException_h
31 #include <ctkCoreExport.h>
106 virtual const
char* name() const throw();
112 virtual const
char* className() const throw();
118 virtual const
char* what() const throw();
124 QString message() const throw();
150 virtual
void rethrow() const;
161 virtual QDebug printStackTrace(QDebug dbg) const;
166 mutable std::
string WhatMsg;
169 void printEnclosedStackTrace(QDebug dbg, const
QList<QString>& enclosingTrace,
170 const QString& caption, const QString& prefix,
179 CTK_CORE_EXPORT QDebug operator<<(QDebug dbg, const
ctkException& exc);
185 CTK_CORE_EXPORT QDebug operator<<(QDebug dbg, const
ctkException::TraceManipulator& trace);
196 #define CTK_DECLARE_EXCEPTION(API, CLS, BASE) \
197 class API CLS : public BASE \
200 explicit CLS(const QString& msg); \
201 CLS(const QString& msg, const ctkException& exc); \
202 CLS(const CLS& exc); \
204 CLS& operator = (const CLS& exc); \
205 const char* name() const throw(); \
206 CLS* clone() const; \
207 void rethrow() const ; \
219 #define CTK_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
220 CLS::CLS(const QString& msg) : BASE(msg) \
222 CLS::CLS(const QString& msg, const ctkException& exc) : BASE(msg, exc) \
224 CLS::CLS(const CLS& exc) : BASE(exc) \
226 CLS::~CLS() throw() \
228 CLS& CLS::operator = (const CLS& exc) \
230 BASE::operator = (exc); \
233 const char* CLS::name() const throw() \
237 CLS* CLS::clone() const \
239 return new CLS(*this); \
241 void CLS::rethrow() const \
Obtains a back trace from the current execution context.
TraceManipulator(const ctkException *e)
QDebug print(QDebug dbg) const
The base class for all exceptions defined in CTK.
ctkException(const QString &msg, const ctkException &cause)
Create a new ctkException containing another exception as the cause.
ctkException(const QString &msg)
Create a new ctkException.
ctkException(const ctkException &o)
Copy constructor.
ctkException & operator=(const ctkException &o)
Assignment operator.
#define CTK_DECLARE_EXCEPTION(API, CLS, BASE)
Quickly declare a ctkException sub-class.