[vtkusers] catching VTK errors

Mark Wyszomierski markww at gmail.com
Mon Aug 6 23:55:07 EDT 2007


Well after some reading it seems VTK doesn't implement exceptions. So
I wrote a small observer class and am observing errors and warnings on
vtkDICOMImageReader. It works, but it seems like such a massive
solution to what might be just a one line simple if () check statement
to see if Update() was successful or not.

Have I done this correctly, or is there a simpler solution?

Thanks,
Mark

On 8/6/07, Mark Wyszomierski <markww at gmail.com> wrote:
> Hi Mathieu,
>
> That's what I'd like to do, I just am not sure how to trap errors. For
> instance, I'm using vtkDICOMImageReader. The reading of the files
> occurs when I call Update(). But that call returns void, yet that's
> where the error occurs and the vtkOutput window pops up at that
> moment. I'd like to do something like:
>
>     try {
>         pMyDicomReader->Update(); // read all the files
>     }
>     catch (vtkDICOMImageReaderError& err)
>     {
>          MessageBox(err); // whatever the error is
>     }
>
> Right now I don't seem to have any way to trap simple errors like no
> DICOM images in the directory etc.
>
> Thanks,
> Mark
>
>
> On 8/6/07, Mathieu Coursolle <mcoursolle at rogue-research.com> wrote:
> > Hi,
> >
> > I am not sure if this is what you are experiencing, but
> > some text is printed to the output (stdout and/or stderr) when some errors
> > occur.
> >
> > On some platform (ex: Windows), those are set to the console by default,
> > so a console appears
> > when something is printed to stdout or stderr.
> >
> > A solution would be to redirect those (stdout, stderr) to a temporary
> > file for example.
> >
> > I tried it once and it worked fine.
> >
> > Thanks.
> >
> > Mathieu
> >
> >
> > --
> > ____________________________________________________________
> > Mathieu Coursolle                   mcoursolle at rogue-research.com
> > Rogue Research                      www.rogue-research.com
> > Montréal, Québec, Canada
> >
> >
> > >Hi,
> > >
> > >How does one catch the vtk debugger window that sometimes pops up when
> > >an error occurs? I'd like to catch it 'gracefully' and die.
> > >
> > >Thanks,
> > >Mark
> > >_______________________________________________
> > >This is the private VTK discussion list.
> > >Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/
> > >VTK_FAQ
> > >Follow this link to subscribe/unsubscribe:
> > >http://www.vtk.org/mailman/listinfo/vtkusers
> > >
> >
> >
> >
> >
>



More information about the vtkusers mailing list