[Insight-users] Python wrapping + exceptions

Charl P. Botha c . p . botha at ewi . tudelft . nl
Tue, 15 Jul 2003 23:55:12 +0100


Dear list,

In Insight, error conditions are often handled by calling 
ITKExceptionMacro which on its part throws a C++ exception.  This is all 
fine and well for C++ applications, where these can be neatly caught.

In the Python wrapping however, there is no catch for the exception, so 
the whole wrapped ITK application is unceremoniously terminated.  Am I 
missing something?

If not, perhaps an itk::Object static variable that changes the 
ITKException behaviour to an that of onITKErrorMacro (still to be 
created, but it looks a lot like ITKWarningMacro) would be appropriate. 
  ITKErrorMacro would invoke an event that would trigger the appropriate 
observers or output an error message if no observers have been 
registered.  Yes, this is almost exactly like VTKErrorMacro. :)

Are there better ways to solve this?  If not, I can start making a patch 
to implement this.

Thanks,
Charl

-- 
charl p. botha http://cpbotha . net/ http://visualisation . tudelft . nl/