Managing errors generated by third party software (VTK) called via PyCall


#1

I am trying to properly manage the exceptions created by an external software, VTK. I am calling some of its functions from PyCall as in the following example.

using PyCall
@pyimport vtk as vtk
reader = vtk.vtkXMLUnstructuredGridReader()
reader[:SetFileName]("test") #Doesn't exist
try
     reader[:Update]()
catch
     println("Error")
end

But the following window shows up instead and crashes Julia. Any idea what I am doing wrong?


#2

This is not really a Julia issue, but a library design issue to be aware of – you would have the same issue in Python. There are many discussions about error handling on the VTK mailing lists and elsewhere, e.g.:

https://stackoverflow.com/questions/23573707/disable-or-catch-vtk-warnings-in-vtkoutputwindow-when-embedding-mayavi