[vtk-developers] trouble with file writers and error handling

Sean McBride sean at rogue-research.com
Fri Dec 5 12:23:05 EST 2014


Hi all,

How is one supposed to check errors when using say vtkSTLWriter?

The docs for "int vtkWriter::Write	(		)" say "Returns 1 on success and 0 on failure" which I thought was sufficient to know at least success/fail.  But it's implementation is:

int vtkWriter::Write()
{
  // Make sure we have input.
  if (this->GetNumberOfInputConnections(0) < 1)
    {
    vtkErrorMacro("No input provided!");
    return 0;
    }

  // always write even if the data hasn't changed
  this->Modified();
  this->UpdateWholeExtent();
  return 1;
}

So it basically always returns success. :(

vtkSTLWriter::WriteData()'s implementation calls a lot of this:

 this->SetErrorCode(vtkErrorCode::NoFileNameError);

So is one expected to call GetErrorCode() after Write()?

Should vtkWriter::Write() be changed to return something like:

 return (this->GetErrorCode == vtkErrorCode::NoError);

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada




More information about the vtk-developers mailing list