Try and except problem when LegacyVTKReader is run

Hi,

This is a simple question which I am unable to resolve it. So, here is the thing.

I have a vtk file which is read through LegacyVTKReader. I am using python exception handling to print an exception error if file is not present. But, I am unable to print the exception error and instead it prints as 'NoneType' object has no attribute 'NewInstance'.

How to change to proper exception handling such that if file is not present, it shows exception error?

My code of exception handling is below.

try:
 pv_reader = LegacyVTKReader(FileNames=[vtk_file_path])
except FileNotFoundError:
 print('vtk file is not present')

Any leads will be appreciated.

Regards,
Sunag R A.

I’m no python expert, but I think the FileNotFoundError is never sent. Why do you expect it ? ParaView do not use exception at all.