[vtkusers] advanced Python VTK error handling

Charl P. Botha cpbotha at gmail.com
Tue Nov 8 06:49:46 EST 2005


Dear VTK users,

The topic of error handling in VTK has come up quite often, especially
in the light of the fact that VTK does now throw exceptions, but
instead either outputs the error message (using the vtkOutputWindow
class) or calls the ErrorEvent observer of an object, if such an
observer has been attached.  There is no really straight-forward way
to trap all errors globally.

One way is to override the vtkOutputWindow, but then one does not get
any information about the object that caused the error.  Another way
is to attach ErrorEvent observers to all VTK objects.

I have made an example [1] to illustrate how one could go about
automatically assigning an ErrorEvent handler to every VTK object that
is instantiated in Python.  By overriding the ModuleType and using a
trick to apply the new type to the imported VTK module
(metaclass-like), we can attach behaviours in a minimally-invasive
fashion to all VTK objects.  Adding observers is a specific example of
this.

What devices are other people using for error-handling in large VTK
projects?  I would welcome discussion on this.

Thanks,
Charl

[1] http://cpbotha.net/thingies/eo_magic.py

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



More information about the vtkusers mailing list