[vtk-developers] C++ exception handling in vtkWrapPython.c

Brad King brad.king at kitware.com
Tue Aug 1 14:06:55 EDT 2006


Charl P. Botha wrote:
> Dear developers,
> 
> Today I spent an hour or two working on a patch for vtkWrapPython.c to
> add try ... catch exception handling around each call to a C++ class
> method.  Afterwards, I discovered that I'd already done this in 2004
> [1].  Oi.  The patch I have now is identical except for the #include
> <vtkstd/stdexcept> I have now instead of the old #include <exception>.
> 
> [1]
> http://public.kitware.com/pipermail/vtk-developers/2004-March/002806.html

This is already done in vtkWrapTcl.c so you can just port the fix from
there.  Don't bother with catch(...) at all.  Just catching
vtkstd::exception should be fine.

> The major problem
> with VTK is that if a class early in a pipeline runs into some error,
> the whole pipeline continues executing if one does not explicitly
> check for problems everywhere.
[snip]
> 1. What are the current thoughts on this and other forms of improved
> global error handling?

The VTK 5.0 pipeline does not keep executing.  If one algorithm fails
the error is reported and the executives do not ask any more algorithms
to run.

VTK code is not anywhere close to exception safe.  Alot of the basic
conventions were established before C++ even had exceptions.  Trying to
use exceptions to escape from filters on error will probably result in
resource leaks, which does not even meet the basic exception guarantee.
 Fixing this now would require several major convention changes, wrapper
parser/generator enhancements, and a huge manual sweep through the code :(

> 2. Is it okay if I disable those pesky "warning C4702: unreachable
> code" errors in VS.NET 7.1 that I get for many of my catch {} clauses?

Yes.

-Brad



More information about the vtk-developers mailing list