[vtk-developers] PLY reader issues

David Cole david.cole at kitware.com
Thu Nov 15 11:29:31 EST 2007


On 11/15/07, Sean McBride <sean at rogue-research.com> wrote:
> Someone on vtk-users also pointed out that this code calls 'exit(-1)' on
> error.  Of course, this terminates the process, loosing any unsaved
> work.  What should it do instead?

Anything but...


> What is VTK's preferred error
> handling mechanism?

Most places where errors occur in VTK simply use vtkErrorMacro and do
an early return. It is not a very robust generic error/exception
handling mechanism and relies on avoiding errors in the first place.
Using vtkErrorMacro consistently at least informs the developer that
something is wrong to fix the calling code. For robust end user
applications, it is up to the application developer to avoid
vtkErrorMacro cases in the first place.

In the case of a reader like this, there should maybe be a CanReadFile
method that guarantees not to error out, but to return whether it will
succeed when it is read in... (vtkBMPReader has one of these, for
example.) Then an end user application could call that method first to
avoid sticking a bogus PLY reader into a VTK pipeline.

HTH,
David



More information about the vtk-developers mailing list