[Insight-users] Python wrapping + exceptions
Luis Ibanez
luis . ibanez at kitware . com
Tue, 15 Jul 2003 20:44:28 -0400
Hi Charl,
Your observation is correct,
ITK is throwing a C++ exception that is not being catched.
The ideal fix would be to figure out a mechanism for catching
C++ exceptions and translate them into Python exceptions.
Your suggestion is a nice option too, since at least the
error message will be available before the program terminates.
The challenge would be to implement this in a way that is
not too invasive on the C++ side.
If you see a viable way of implementing this, we will be
happy to incorporate it on the toolkit.
Thanks
Luis
---------------------
Charl P. Botha wrote:
> 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
>