[vtk] Error handling

M.Schrijver at el.utwente.nl M.Schrijver at el.utwente.nl
Fri Jul 9 05:05:02 EDT 1999


Yes, it seems to me you are right. The problem is not however with the
try/catch system, since it is specifically designed to handle such
situations. The stack is unwind untill it reaches a level where you can
properly deal with the error, and that where you should put the catch
block. The problem is much more the 'demand driven' operation of vtk.
The bad file (or whatever) is first encountered when you call Render(),
and that indeed is not a good place to try to fix the error condition.

What you do need is a system that let objects themselves solve their
problems! Agree? So, one solution I can think of right now is to add a
member function (virtual, but not pure virtual) to vtkObject, like 'int
HandleError()' or something. The default implementation would do
nothing, but every class (the reader you are talking about, or any other
class possibly encountering solvable error conditions) can define their
own versions of this method. Now, by changing vtkSetGet.h to call this
member from within vtkErrorMacro would automatically call the correct
code. Using the return value, you can find out whether the method
succeeded in solving the problem, and the program should continue, or
terminate, or .... (?)

One problem with this approach is probably that it is very hard to
incorporate such an addition in the vtk distribution due to differences
in operating systems (e.g. displaying a file selection dialog is highly
OS dependent), and user preferences. So, maybe an even better approach
is to allow users to install their own error-handler in each instance.
Something similar to the StartMethod, ProgressMethod, EndMethod, etc.
approach. So, maybe vtkProcessObject::SetErrorHandler() ?

Succes, Marc

P.S. maybe someone can come up with some useful parameters to pass to
the error handler? Error code, text string describing the error,
severity, etc. ?

ir. Marc Schrijver
Faculty of Electrical Engineering (S&S NT)
University of Twente
The Netherlands

> ----------
> From: 	Roland Schwarz[SMTP:roland.schwarz at telecom.at]
> Sent: 	Friday, July 09, 1999 9:18 AM
> To: 	users VTK
> Subject: 	[vtk] Error handling
> 
> Dear VTK Users,
>     I wonder if anyone can tell me how to do proper error
> handling in VTK. I am relatively new to VTK and have
> only limited understanding of the inner workings of the
> visualization pipeline. Yes I have read the book 'The Visualization
> Toolkit' and also bought the printed users manual.
> 
> I have come over this question as I tried to set different 
> input files for the reader. Now if the file is in error i.e. has
> corrupt data, this first results in a call to an error macro and
> then in a pop up message. The only coice at this point is
> to terminate the application or to leave the piplene in an
> inconsistent state. The latter is bad since this will trigger
> some VERY bad things as invalid pointer derefs and that
> like.
> 
> What I would like to do is giving the user an option to choose
> a different file or otherwise be able to correct this error. (I expect
> similar problems when manipulating the pipeline in other
> ways that can result in errors.)
> 
> The first idea that came to me was to use the C++ throw and catch
> mechanism triggered from the vtkObject::BreakOnError member.
> But that will end up at the point where an Update was requested
> what is likely a bad place to actually correct the error.
> 
> This kind of things must have been solved by some other users
> and I am sure that I am missing something so please give me
> any pointers where to learn about this (I did'nt find anything in the
> FAQ too).
> 
> Thank you, 
> Roland.
> 
> Dipl.-Ing. Roland Schwarz
> Business Email: RSchwarz at riegl.co.at
> Private Email: roland.schwarz at telecom.at
> 
> 
> 
> ----------------------------------------------------------------------
> -------
> This is the private VTK discussion list.  Please keep messages
> on-topic.
> Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
> <majordomo at gsao.med.ge.com>.  For help, send message body containing
> "info vtkusers" to the same address.     Live long and prosper.
> ----------------------------------------------------------------------
> -------
> 


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list