18 #ifndef itkExceptionObject_h
19 # error "Do not include itkExceptionObject.h directly, include itkMacro.h instead."
20 #else // itkExceptionObject_h
48 class ITKCommon_EXPORT ExceptionObject :
public std::exception
51 static constexpr
const char *
const default_exception_message =
"Generic ExceptionObject";
52 using Superclass = std::exception;
56 ExceptionObject() noexcept;
57 explicit ExceptionObject(const
char * file,
58 unsigned int lineNumber = 0,
59 const
char * desc = "None",
60 const
char * loc = "Unknown");
61 explicit ExceptionObject(std::
string file,
62 unsigned int lineNumber = 0,
63 std::
string desc = "None",
64 std::
string loc = "Unknown");
65 ExceptionObject(const ExceptionObject & orig) noexcept;
69 ~ExceptionObject() noexcept override;
73 operator=(const ExceptionObject & orig) noexcept;
77 operator==(const ExceptionObject & orig);
80 GetNameOfClass()
const
82 return "ExceptionObject";
90 Print(std::ostream & os)
const;
96 SetLocation(
const std::string & s);
99 SetDescription(
const std::string & s);
102 SetLocation(
const char * s);
105 SetDescription(
const char * s);
111 GetDescription()
const;
123 what() const noexcept override;
151 class ReferenceCounterInterface
155 Register()
const = 0;
158 UnRegister()
const = 0;
160 ReferenceCounterInterface();
161 virtual ~ReferenceCounterInterface();
164 class ReferenceCountedExceptionData;
165 SmartPointer<const ReferenceCounterInterface> m_ExceptionData;
166 const ExceptionData *
167 GetExceptionData()
const;
171 inline std::ostream &
172 operator<<(std::ostream & os,
const ExceptionObject &
e)
188 class ITKCommon_EXPORT MemoryAllocationError :
public ExceptionObject
193 MemoryAllocationError() noexcept
198 MemoryAllocationError(
const char * file,
unsigned int lineNumber)
199 : ExceptionObject(file, lineNumber)
203 MemoryAllocationError(
const std::string & file,
unsigned int lineNumber)
204 : ExceptionObject(file, lineNumber)
208 MemoryAllocationError(
const std::string & file,
209 unsigned int lineNumber,
210 const std::string & desc,
211 const std::string & loc)
212 : ExceptionObject(file, lineNumber, desc, loc)
216 ~MemoryAllocationError() noexcept override;
219 GetNameOfClass()
const override
221 return "MemoryAllocationError";
230 class ITKCommon_EXPORT RangeError :
public ExceptionObject
235 RangeError() noexcept
240 RangeError(
const char * file,
unsigned int lineNumber)
241 : ExceptionObject(file, lineNumber)
245 RangeError(
const std::string & file,
unsigned int lineNumber)
246 : ExceptionObject(file, lineNumber)
250 ~RangeError() noexcept override;
253 GetNameOfClass()
const override
265 class ITKCommon_EXPORT InvalidArgumentError :
public ExceptionObject
272 InvalidArgumentError() noexcept
279 InvalidArgumentError(
const char * file,
unsigned int lineNumber)
280 : ExceptionObject(file, lineNumber)
286 InvalidArgumentError(
const std::string & file,
unsigned int lineNumber)
287 : ExceptionObject(file, lineNumber)
291 ~InvalidArgumentError() noexcept override;
294 GetNameOfClass()
const override
296 return "InvalidArgumentError";
305 class ITKCommon_EXPORT IncompatibleOperandsError :
public ExceptionObject
310 IncompatibleOperandsError() noexcept
315 IncompatibleOperandsError(
const char * file,
unsigned int lineNumber)
316 : ExceptionObject(file, lineNumber)
320 IncompatibleOperandsError(
const std::string & file,
unsigned int lineNumber)
321 : ExceptionObject(file, lineNumber)
325 ~IncompatibleOperandsError() noexcept override;
328 GetNameOfClass()
const override
330 return "IncompatibleOperandsError";
339 class ITKCommon_EXPORT ProcessAborted :
public ExceptionObject
347 this->SetDescription(
"Filter execution was aborted by an external request");
351 ProcessAborted(
const char * file,
unsigned int lineNumber)
352 : ExceptionObject(file, lineNumber)
354 this->SetDescription(
"Filter execution was aborted by an external request");
358 ProcessAborted(
const std::string & file,
unsigned int lineNumber)
359 : ExceptionObject(file, lineNumber)
361 this->SetDescription(
"Filter execution was aborted by an external request");
365 ~ProcessAborted() noexcept override;
368 GetNameOfClass()
const override
370 return "ProcessAborted";
375 #endif // itkExceptionObject_h