18 #ifndef itkExceptionObject_h
19 # error "Do not include itkExceptionObject.h directly, include itkMacro.h instead."
20 #else // itkExceptionObject_h
47 class ITKCommon_EXPORT ExceptionObject :
public std::exception
50 static constexpr
const char *
const default_exception_message =
"Generic ExceptionObject";
51 using Superclass = std::exception;
54 ExceptionObject() noexcept = default;
56 explicit ExceptionObject(const
char * file,
57 unsigned int lineNumber = 0,
58 const
char * desc = "None",
59 const
char * loc = "Unknown");
60 explicit ExceptionObject(std::
string file,
61 unsigned int lineNumber = 0,
62 std::
string desc = "None",
63 std::
string loc = "Unknown");
66 ExceptionObject(const ExceptionObject &) noexcept = default;
69 ExceptionObject(ExceptionObject &&) noexcept = default;
73 operator=(const ExceptionObject &) noexcept = default;
77 operator=(ExceptionObject &&) noexcept = default;
81 ~ExceptionObject() override;
85 operator==(const ExceptionObject & orig) const;
88 GetNameOfClass()
const
90 return "ExceptionObject";
98 Print(std::ostream & os)
const;
104 SetLocation(
const std::string & s);
107 SetDescription(
const std::string & s);
110 SetLocation(
const char * s);
113 SetDescription(
const char * s);
119 GetDescription()
const;
131 what() const noexcept override;
136 std::shared_ptr<const ExceptionData> m_ExceptionData;
140 inline std::ostream &
141 operator<<(std::ostream & os, const ExceptionObject &
e)
157 class ITKCommon_EXPORT MemoryAllocationError :
public ExceptionObject
161 using ExceptionObject::ExceptionObject;
164 GetNameOfClass()
const override
166 return "MemoryAllocationError";
175 class ITKCommon_EXPORT RangeError :
public ExceptionObject
179 using ExceptionObject::ExceptionObject;
182 GetNameOfClass()
const override
194 class ITKCommon_EXPORT InvalidArgumentError :
public ExceptionObject
198 using ExceptionObject::ExceptionObject;
201 GetNameOfClass()
const override
203 return "InvalidArgumentError";
212 class ITKCommon_EXPORT IncompatibleOperandsError :
public ExceptionObject
216 using ExceptionObject::ExceptionObject;
219 GetNameOfClass()
const override
221 return "IncompatibleOperandsError";
230 class ITKCommon_EXPORT ProcessAborted :
public ExceptionObject
238 this->SetDescription(
"Filter execution was aborted by an external request");
242 ProcessAborted(
const char * file,
unsigned int lineNumber)
243 : ExceptionObject(file, lineNumber)
245 this->SetDescription(
"Filter execution was aborted by an external request");
249 ProcessAborted(
const std::string & file,
unsigned int lineNumber)
250 : ExceptionObject(file, lineNumber)
252 this->SetDescription(
"Filter execution was aborted by an external request");
256 GetNameOfClass()
const override
258 return "ProcessAborted";
263 #endif // itkExceptionObject_h