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 itkTypeMacroNoParent(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 itkTypeMacro(MemoryAllocationError, ExceptionObject);
171 class ITKCommon_EXPORT RangeError :
public ExceptionObject
175 using ExceptionObject::ExceptionObject;
178 itkTypeMacro(RangeError, ExceptionObject);
187 class ITKCommon_EXPORT InvalidArgumentError :
public ExceptionObject
191 using ExceptionObject::ExceptionObject;
194 itkTypeMacro(InvalidArgumentError, ExceptionObject);
202 class ITKCommon_EXPORT IncompatibleOperandsError :
public ExceptionObject
206 using ExceptionObject::ExceptionObject;
209 itkTypeMacro(IncompatibleOperandsError, ExceptionObject);
217 class ITKCommon_EXPORT ProcessAborted :
public ExceptionObject
225 this->SetDescription(
"Filter execution was aborted by an external request");
229 ProcessAborted(
const char * file,
unsigned int lineNumber)
230 : ExceptionObject(file, lineNumber)
232 this->SetDescription(
"Filter execution was aborted by an external request");
236 ProcessAborted(
const std::string & file,
unsigned int lineNumber)
237 : ExceptionObject(file, lineNumber)
239 this->SetDescription(
"Filter execution was aborted by an external request");
243 itkTypeMacro(ProcessAborted, ExceptionObject);
247 #endif // itkExceptionObject_h