Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitk::Exception Class Reference

An object of this class represents an exception of MITK. Please don't instantiate exceptions manually, but use the exception macros (file mitkExceptionMacro.h) instead. Simple use in your code is: More...

#include <mitkException.h>

Inheritance diagram for mitk::Exception:
Collaboration diagram for mitk::Exception:

Classes

struct  ReThrowData
 

Public Member Functions

 Exception (const char *file, unsigned int lineNumber=0, const char *desc="None", const char *loc="Unknown")
 
 ~Exception () override throw ()
 
virtual const char * GetClassName () const
 
void AddRethrowData (const char *file, unsigned int lineNumber, const char *message)
 Adds rethrow data to this exception. More...
 
int GetNumberOfRethrows ()
 
void GetRethrowData (int rethrowNumber, std::string &file, int &line, std::string &message)
 
template<class T >
Exceptionoperator<< (const T &data)
 Definition of the bit shift operator for this class. More...
 
template<class T >
Exceptionoperator<< (T &data)
 Definition of the bit shift operator for this class (for non const data). More...
 
Exceptionoperator<< (std::ostream &(*func)(std::ostream &))
 Definition of the bit shift operator for this class (for functions). More...
 

Protected Attributes

std::vector< ReThrowDatam_RethrowData
 

Detailed Description

An object of this class represents an exception of MITK. Please don't instantiate exceptions manually, but use the exception macros (file mitkExceptionMacro.h) instead. Simple use in your code is:

Documentation

    mitkThrow() << "optional exception message";

You can also define specialized exceptions which must inherit from this class. Please always use the mitkExceptionClassMacro when implementing specialized exceptions. A simple implementation can look like:

class MyException : public mitk::Exception { public: mitkExceptionClassMacro(MyException,mitk::Exception); };

You can then throw your specialized exceptions by using the macro

   mitkThrowException(MyException) << "optional exception message";

Definition at line 45 of file mitkException.h.

Constructor & Destructor Documentation

◆ Exception()

mitk::Exception::Exception ( const char *  file,
unsigned int  lineNumber = 0,
const char *  desc = "None",
const char *  loc = "Unknown" 
)
inline

Definition at line 48 of file mitkException.h.

◆ ~Exception()

mitk::Exception::~Exception ( )
throw (
)
inlineoverride

Definition at line 53 of file mitkException.h.

Member Function Documentation

◆ AddRethrowData()

void mitk::Exception::AddRethrowData ( const char *  file,
unsigned int  lineNumber,
const char *  message 
)

Adds rethrow data to this exception.

◆ GetClassName()

virtual const char* mitk::Exception::GetClassName ( ) const
virtual

◆ GetNumberOfRethrows()

int mitk::Exception::GetNumberOfRethrows ( )
Returns
Returns how often the exception was rethrown.

◆ GetRethrowData()

void mitk::Exception::GetRethrowData ( int  rethrowNumber,
std::string &  file,
int &  line,
std::string &  message 
)

Returns the rethrow data of the specified rethrow number. Returns empty data, if the rethrowNumber doesn't exist.

Parameters
rethrowNumberThe internal number of the rethrow.
file(returnvalue) This variable will be filled with the file of the specified rethrow.
line(returnvalue) This variable will be filled with the line of the specified rethrow.
message(returnvalue) This variable will be filled with the message of the specified rethrow.

◆ operator<<() [1/3]

template<class T >
Exception& mitk::Exception::operator<< ( const T &  data)
inline

Definition of the bit shift operator for this class.

Definition at line 74 of file mitkException.h.

◆ operator<<() [2/3]

Exception& mitk::Exception::operator<< ( std::ostream &(*)(std::ostream &)  func)
inline

Definition of the bit shift operator for this class (for functions).

Definition at line 93 of file mitkException.h.

◆ operator<<() [3/3]

template<class T >
Exception& mitk::Exception::operator<< ( T &  data)
inline

Definition of the bit shift operator for this class (for non const data).

Definition at line 84 of file mitkException.h.

Member Data Documentation

◆ m_RethrowData

std::vector<ReThrowData> mitk::Exception::m_RethrowData
protected

Definition at line 109 of file mitkException.h.


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