[Insight-developers] SimpleITK Exceptions

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Mar 14 17:03:01 EDT 2011


Jim,

Currently, itk::simple::GenericException is derived from itk::ExceptionObject. You can catch which ever types of exception you prefer, both of your suggestions would currently work. This is one of the few places where SimpleITK is depending on ITK in the headers. So that SimpleITK will not need to include ITK headers to become a standalone library, the SimpleITK exception needs to be rewritten to derived directly from an std::exception, and not itk's exception.

After this change, more thought will need to be put into how to deal with ITK exceptions inside SimpleITK. Currently I am thinking that one of the SimpleITK exception types could hold a ITK exception so it could be accessed via a pointer if needed. This would enable the ITK exception to have a forward declaration. Do you have other suggestions for this?

I don't think it is in the plan to add exception specification to the SimpleITK members or functions. So if you must have an application robust to exceptions you will still need to catch(...) to guarantee getting all cases.

Brad

On Mar 14, 2011, at 4:44 PM, Jim Miller wrote:

> It doesn't appear as though SimpleITK catches ITK exceptions (and translate them into SimpleITK exceptions). Is the expectation that users will explicitly catch both itk::simple::GenericException and itk::ExceptionObject? Or perhaps just catch itk::ExceptionObject as it appears as though itk::simple::GenericException derives from itk::ExceptionObject.
> 
> 
> Jim Miller
> Senior Scientist
> GE Research 
> Interventional and Therapy
> 
> GE imagination at work
> 
> <smime.p7s><ATT00001..txt>



========================================================
Bradley Lowekamp  
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110314/90214883/attachment-0001.htm>


More information about the Insight-developers mailing list