Hi Willi,<div><br></div><div>You can capture errors globally and send them to a log file,</div><div>by using e.g. vtkFileOutputWindow.  Or you can write a custom</div><div>OutputWindow class that pops up a modal dialog box and</div>

<div>requires your customers to press &quot;Okay&quot; or &quot;Cancel&quot; before</div><div>proceeding.</div><div><br></div><div> - David<br><br><div class="gmail_quote">On Wed, Jan 9, 2013 at 11:56 AM, Willi Huber <span dir="ltr">&lt;<a href="mailto:w.huber@ymail.com" target="_blank">w.huber@ymail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><p>Hey David,</p>
<p>yeah it was the right problem you are assuming. <br>
Is there a way to catch errors like this or do I have to tell my &quot;customers&quot; to copy what they can read (if they can read it) in the popup window?<br>
In my opinion this kind of error handling ain&#39;t a good solution if wrapping is a feature VTK offers. Can it be stopped that my app is going to be killed in such a harsh way?</p>
<p>Cheers,<br>
Willi</p>
</td></tr></tbody></table>            <div>
                <div>
                    <br>
                    <div style="font-family:times new roman,new york,times,serif;font-size:12pt">
                        <font face="Tahoma">
                            <hr size="1">
                            <b>
                                <span style="font-weight:bold">From:</span>
                            </b>
                            David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>&gt;;                            <br>
                            <b>
                                <span>To:</span>
                            </b>
                            Willi Huber &lt;<a href="mailto:surfersparadise85-vtk@yahoo.com" target="_blank">surfersparadise85-vtk@yahoo.com</a>&gt;;                                                     <br>
                            <b>
                                <span>Cc:</span>
                            </b>
                            <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a> &lt;<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>&gt;;                                                                             <br>


                            <b>
                                <span>Subject:</span>
                            </b>
                            Re: [vtkusers] Python observer handling                            <br>
                            <b>
                                <span style="font-weight:bold">Sent:</span>
                            </b>
                            Wed, Jan 9, 2013 6:15:34 PM                            <br>
                            </font><div><div class="h5">
                            <br>
                            <table cellspacing="0" cellpadding="0" border="0">
                                <tbody>
                                    <tr>
                                        <td valign="top" style="font:inherit">Hi Willi,<br><br>I quickly ran your python code (on my Mac), and saw an error like this<br>in the console:<br><br>ERROR: In vtkDemandDrivenPipeline.cxx, line 816<br>

vtkStreamingDemandDrivenPipeline (0x1044d38a0): Input for connection<br>index 0 on input port index 0 for algorithm<br>vtkPainterPolyDataMapper(0x1044cf970) is of type vtkImageData, but a<br>vtkPolyData is required.<br><br>

So in my case, it wasn&#39;t the mapper that generated this error: it was<br>the mapper&#39;s executive, which is a different object.  Also, many of<br>the VTK mappers delegate to other VTK mappers, and because these<br>
delegate mappers are created internally you will not be able to add<br>
observers to them.  I&#39;m not saying this is a good thing... it is a bad<br>thing, obviously, but ErrorObservers cannot always be used<br>successfully with mappers.  On the positive side, ErrorObservers
 work<br>nicely with readers.<br><br>For your code specifically, I&#39;m guessing that you are seeing an error<br>because you are using an image as input to a vtkPolyDataMapper.<br><br> - David<br><br><br>On Wed, Jan 9, 2013 at 9:20 AM, Willi Huber<br>

&lt;<a>surfersparadise85-vtk@yahoo.com</a>&gt; wrote:<br>&gt; Hello all,<br>&gt;<br>&gt; I know exception handling in VTK has been discussed quite a while so I don&#39;t<br>&gt; want to add insult to an injury.<br>&gt;<br>

&gt; Since David Gobbi very often posted his code:<br>&gt;<br>&gt; ==== python code ====<br>&gt; import vtk<br>&gt;<br>&gt; class ErrorObserver:<br>&gt;<br>&gt;    def __init__(self):<br>&gt;        self.__ErrorOccurred = False<br>

&gt;        self.__ErrorMessage = None<br>&gt;        self.CallDataType = &#39;string0&#39;<br>&gt;<br>&gt;    def
 __call__(self, obj, event, message):<br>&gt;        self.__ErrorOccurred = True<br>&gt;        self.__ErrorMessage = message<br>&gt;<br>&gt;    def ErrorOccurred(self):<br>&gt;        occ = self.__ErrorOccurred<br>&gt;        self.__ErrorOccurred = False<br>

&gt;        return occ<br>&gt;<br>&gt;    def ErrorMessage(self):<br>&gt;        return self.__ErrorMessage<br>&gt;<br>&gt; e = ErrorObserver()<br>&gt;<br>&gt; a = vtk.vtkImageReader()<br>&gt; a.AddObserver(&#39;ErrorEvent&#39;, e)<br>

&gt;<br>&gt; print &quot;doing update&quot;<br>&gt; a.Update()<br>&gt; if e.ErrorOccurred():<br>&gt;    print e.ErrorMessage()<br>&gt;<br>&gt; ==== python code ====<br>&gt;<br>&gt;<br>&gt; Unfortunately it is not working as intended. I tried this code which<br>

&gt; obviously had to fail:<br>&gt;<br>&gt; ==== python code ====<br>&gt;<br>&gt;
 mapper = vtk.vtkPolyDataMapper()<br>&gt; mapper.AddObserver(&#39;ErrorEvent&#39;, e)<br>&gt; mapper.SetInputConnection(reader.GetOutputPort()) #reader is of type<br>&gt; vtkMetaImageReader<br>&gt; mapper.Update()<br>&gt;<br>

&gt; if e.ErrorOccurred():<br>&gt;    print e.ErrorMessage()<br>&gt; else:<br>&gt;    print &quot;No Error&quot;<br>&gt;<br>&gt; ==== python code ====<br>&gt;<br>&gt; but it didn&#39;t. Now I know about this error but I am still curious why it was<br>

&gt; not working as intended.<br>&gt;<br>&gt; Shouldn&#39;t it print the cause of the error rather than &quot;No Error&quot;?<br>&gt;<br>&gt;<br>&gt; Everytime I tried this code a vtk warning window poped up which can&#39;t be<br>

&gt; read since the whole application dies with some Windows failure handling.<br>&gt; Therefore I was not able to read the error message in the window and had a<br>&gt; tough time finding out about the problem.<br>&gt;  Uncommenting renWin.Render() let me read the
 error.<br>&gt;<br>&gt; Any suggestions what I am doing wrong?<br>&gt;<br>&gt;<br>&gt; Cheers,<br>&gt;<br>&gt; Willi<br></td>
                                    </tr>
                                </tbody>
                            </table>
                    </div></div></div>
                </div>
            </div>
</blockquote></div><br></div>