Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitkExceptionMacro.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkExceptionMacro_h
14 #define mitkExceptionMacro_h
15 
16 #include "mitkException.h"
17 #include <itkMacro.h>
18 #include <mitkLog.h>
19 #include <sstream>
20 
27 #define mitkThrow() throw mitk::Exception(__FILE__, __LINE__, "", ITK_LOCATION)
28 
45 #define mitkReThrow(mitkexception) \
46  mitkexception.AddRethrowData(__FILE__, __LINE__, "Rethrow by mitkReThrow macro."); \
47  throw mitkexception
48 
57 #define mitkThrowException(classname) throw classname(__FILE__, __LINE__, "", ITK_LOCATION)
58 
62 #define mitkExceptionClassMacro(ClassName, SuperClassName) \
63  ClassName(const char *file, unsigned int lineNumber, const char *desc, const char *loc) \
64  : SuperClassName(file, lineNumber, desc, loc) \
65  { \
66  } \
67  itkTypeMacro(ClassName, SuperClassName); \
68  \
69  template <class T> \
70  inline ClassName &operator<<(const T &data) \
71  { \
72  std::stringstream ss; \
73  ss << this->GetDescription() << data; \
74  this->SetDescription(ss.str()); \
75  return *this; \
76  } \
77  \
78  template <class T> \
79  inline ClassName &operator<<(T &data) \
80  { \
81  std::stringstream ss; \
82  ss << this->GetDescription() << data; \
83  this->SetDescription(ss.str()); \
84  return *this; \
85  } \
86  \
87  inline ClassName &operator<<(std::ostream &(*func)(std::ostream &)) \
88  { \
89  std::stringstream ss; \
90  ss << this->GetDescription() << func; \
91  this->SetDescription(ss.str()); \
92  return *this; \
93  }
94 
95 #endif
mitkException.h
mitkLog.h