CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
ctkException Class Reference

The base class for all exceptions defined in CTK. More...

#include <Libs/Core/ctkException.h>

Inheritance diagram for ctkException:
Inheritance graph
[legend]
Collaboration diagram for ctkException:
Collaboration graph
[legend]

Classes

class  TraceManipulator
 

Public Member Functions

const ctkExceptioncause () const throw ()
 Gets the nested exception which caused this exception. More...
 
virtual const char * className () const throw ()
 Returns the class name for this exception. More...
 
virtual ctkExceptionclone () const
 Creates a copy of this exception. Use rethrow() to throw the copy again. More...
 
 ctkException (const ctkException &o)
 Copy constructor. More...
 
 ctkException (const QString &msg)
 Create a new ctkException. More...
 
 ctkException (const QString &msg, const ctkException &cause)
 Create a new ctkException containing another exception as the cause. More...
 
QString message () const throw ()
 Returns the detail message string of this exception. More...
 
virtual const char * name () const throw ()
 Returns the name for this exception. More...
 
ctkExceptionoperator= (const ctkException &o)
 Assignment operator. More...
 
TraceManipulator printStackTrace () const
 Returns an object suitable for printing this executable and its backtrace via qDebug(). More...
 
virtual void rethrow () const
 (Re)Throws this exception. More...
 
void setCause (const ctkException &cause)
 Sets the cause for this exception. More...
 
virtual const char * what () const throw ()
 Returns a static string describing this exception. More...
 
 ~ctkException () throw ()
 
- Public Member Functions inherited from ctkBackTrace
 ctkBackTrace (const ctkBackTrace &other)
 
 ctkBackTrace (size_t framesNumber=DefaultStackSize)
 Create a back trace. More...
 
void * returnAddress (unsigned frameNumber) const
 Get the return address for a given stack frame. More...
 
QString stackFrame (unsigned frameNumber) const
 Get a textual representation for a given stack frame. More...
 
size_t stackSize () const
 Get the stack size. More...
 
QList< QString > stackTrace () const
 Provides programmatic access to the stack trace information. More...
 
virtual ~ctkBackTrace () throw ()
 

Protected Member Functions

virtual QDebug printStackTrace (QDebug dbg) const
 Print the stack trace of this exception using the given QDebug object. More...
 

Friends

class TraceManipulator
 

Additional Inherited Members

- Static Public Attributes inherited from ctkBackTrace
static size_t const DefaultStackSize
 

Detailed Description

The base class for all exceptions defined in CTK.

This exception class takes a QString object as the message text and can optionally store another ctkException instance which caused this exception.

ctkException classes can be copied, saved, and rethrown.

Definition at line 45 of file ctkException.h.

Constructor & Destructor Documentation

◆ ctkException() [1/3]

ctkException::ctkException ( const QString &  msg)
explicit

Create a new ctkException.

Parameters
msgThe exception message.

◆ ctkException() [2/3]

ctkException::ctkException ( const QString &  msg,
const ctkException cause 
)

Create a new ctkException containing another exception as the cause.

Parameters
msgThe exception message.
causeThe nested exception causing this exception.

◆ ctkException() [3/3]

ctkException::ctkException ( const ctkException o)

Copy constructor.

Parameters
oThe exception to copy.

◆ ~ctkException()

ctkException::~ctkException ( )
throw (
)

Member Function Documentation

◆ cause()

const ctkException* ctkException::cause ( ) const
throw (
)

Gets the nested exception which caused this exception.

Returns
The nested exception, or NULL if there is none.

◆ className()

virtual const char* ctkException::className ( ) const
throw (
)
virtual

Returns the class name for this exception.

Returns
The exception class name.

Reimplemented in ctkCmdLineModuleTimeoutException, and ctkCmdLineModuleRunException.

◆ clone()

virtual ctkException* ctkException::clone ( ) const
virtual

◆ message()

QString ctkException::message ( ) const
throw (
)

Returns the detail message string of this exception.

Returns
The detail exception message.

◆ name()

virtual const char* ctkException::name ( ) const
throw (
)
virtual

◆ operator=()

ctkException& ctkException::operator= ( const ctkException o)

Assignment operator.

Parameters
oThe exception to assign to this exception.
Returns

◆ printStackTrace() [1/2]

TraceManipulator ctkException::printStackTrace ( ) const

Returns an object suitable for printing this executable and its backtrace via qDebug().

Example usage:

ctkException exc("My error");
qDebug() << exc.printStackTrace();
The base class for all exceptions defined in CTK.
Definition: ctkException.h:46
Returns
A helper object for streaming to qDebug().

◆ printStackTrace() [2/2]

virtual QDebug ctkException::printStackTrace ( QDebug  dbg) const
protectedvirtual

Print the stack trace of this exception using the given QDebug object.

Parameters
dbg
Returns

◆ rethrow()

virtual void ctkException::rethrow ( ) const
virtual

◆ setCause()

void ctkException::setCause ( const ctkException cause)

Sets the cause for this exception.

Parameters
causeThe exception causing this exception.

◆ what()

virtual const char* ctkException::what ( ) const
throw (
)
virtual

Returns a static string describing this exception.

Returns
The exception description.

Friends And Related Function Documentation

◆ TraceManipulator

friend class TraceManipulator
friend

Definition at line 154 of file ctkException.h.


The documentation for this class was generated from the following file: