18 #ifndef itkExceptionObject_h
19 # error "Do not include itkExceptionObject.h directly, include itkMacro.h instead."
20 #else // itkExceptionObject_h
49 class ITKCommon_EXPORT ExceptionObject :
public std::exception
52 static constexpr
const char *
const default_exception_message =
"Generic ExceptionObject";
56 ExceptionObject() noexcept = default;
58 explicit ExceptionObject(const
char * file,
59 unsigned int lineNumber = 0,
60 const
char * desc = "None",
61 const
char * loc = "Unknown");
62 explicit ExceptionObject(std::
string file,
63 unsigned int lineNumber = 0,
64 std::
string desc = "None",
65 std::
string loc = "Unknown");
68 ExceptionObject(const ExceptionObject &) noexcept = default;
71 ExceptionObject(ExceptionObject &&) noexcept = default;
75 operator=(const ExceptionObject &) noexcept = default;
79 operator=(ExceptionObject &&) noexcept = default;
83 ~ExceptionObject() override;
87 operator==(const ExceptionObject & orig) const;
90 itkVirtualGetNameOfClassMacro(ExceptionObject);
97 Print(std::ostream & os) const;
103 SetLocation(const std::
string & s);
106 SetDescription(const std::
string & s);
109 SetLocation(const
char * s);
112 SetDescription(const
char * s);
118 GetDescription() const;
130 what() const noexcept override;
135 std::shared_ptr<const ExceptionData> m_ExceptionData{};
139 inline std::ostream &
140 operator<<(std::ostream & os,
const ExceptionObject &
e)
156 class ITKCommon_EXPORT MemoryAllocationError :
public ExceptionObject
160 using ExceptionObject::ExceptionObject;
163 itkOverrideGetNameOfClassMacro(MemoryAllocationError);
172 class ITKCommon_EXPORT RangeError :
public ExceptionObject
176 using ExceptionObject::ExceptionObject;
179 itkOverrideGetNameOfClassMacro(RangeError);
189 class ITKCommon_EXPORT InvalidArgumentError :
public ExceptionObject
193 using ExceptionObject::ExceptionObject;
196 itkOverrideGetNameOfClassMacro(InvalidArgumentError);
205 class ITKCommon_EXPORT IncompatibleOperandsError :
public ExceptionObject
209 using ExceptionObject::ExceptionObject;
212 itkOverrideGetNameOfClassMacro(IncompatibleOperandsError);
221 class ITKCommon_EXPORT ProcessAborted :
public ExceptionObject
229 this->SetDescription(
"Filter execution was aborted by an external request");
233 ProcessAborted(
const char * file,
unsigned int lineNumber)
234 : ExceptionObject(file, lineNumber)
236 this->SetDescription(
"Filter execution was aborted by an external request");
240 ProcessAborted(
const std::string & file,
unsigned int lineNumber)
241 : ExceptionObject(file, lineNumber)
243 this->SetDescription(
"Filter execution was aborted by an external request");
247 itkOverrideGetNameOfClassMacro(ProcessAborted);
252 #endif // itkExceptionObject_h