Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitkExceptionMacro.h File Reference
#include "mitkException.h"
#include <itkMacro.h>
#include <mitkLog.h>
#include <sstream>

Go to the source code of this file.

Macros

#define mitkThrow()
 
#define mitkReThrow(mitkexception)
 
#define mitkThrowException(classname)
 
#define mitkExceptionClassMacro(ClassName, SuperClassName)
 

Macro Definition Documentation

◆ mitkExceptionClassMacro

#define mitkExceptionClassMacro (   ClassName,
  SuperClassName 
)

Class macro for MITK exception classes. All MITK exception classes should derive from MITK::Exception.

Definition at line 62 of file mitkExceptionMacro.h.

◆ mitkReThrow

#define mitkReThrow (   mitkexception)

The rethrow macro is used to rethrow an existing exception. The rethrow information (file,line of code) is then additionally stored in the exception. To check if an exception was rethrown you can use the methods GetNumberOfRethrows() and GetRethrowData().

Example usage: try { //some code that throws an exception } catch(mitk::Exception e) { //here we want to rethrow the exception mitkReThrow(e) << "Message that will be appended to the exception (optional)"; }

Definition at line 45 of file mitkExceptionMacro.h.

◆ mitkThrow

#define mitkThrow ( )

The exception macro is used to throw an exception (i.e., usually a condition that results in program failure).

Example usage looks like: mitkThrow() << "this is error info";

Definition at line 27 of file mitkExceptionMacro.h.

◆ mitkThrowException

#define mitkThrowException (   classname)

The specialized exception macro is used to throw exceptions in cases of specialized errors. This means the second parameter must be a class which inherits from mitk::Exception. An object of this exception is thrown when using the macro. Thus, more differentiated excaptions can be thrown, when needed.

Example usage: mitkSpecializedExceptionMacro(mitk::MySpecializedException) << "this is error info";

Definition at line 57 of file mitkExceptionMacro.h.