# Try and except problem when LegacyVTKReader is run

**URL:** <https://discourse.vtk.org/t/try-and-except-problem-when-legacyvtkreader-is-run/7884>\
**Category:** Development\
**Tags:** file-formats\
**Created:** [February 21, 2022, 3:36pm UTC](https://discourse.vtk.org/t/try-and-except-problem-when-legacyvtkreader-is-run/7884 "2022-02-21T15:36:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasunag27](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rasunag27/32/3160_2.png) [@rasunag27](https://discourse.vtk.org/u/rasunag27)\
**Post date:** [February 21, 2022, 3:36pm UTC](https://discourse.vtk.org/t/try-and-except-problem-when-legacyvtkreader-is-run/7884/1 "2022-02-21T15:36:49Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)\
**Post date:** [February 22, 2022, 2:31am UTC](https://discourse.vtk.org/t/try-and-except-problem-when-legacyvtkreader-is-run/7884/2 "2022-02-22T02:31:04Z")

</div>

This looks like a ParaView question to me, which I recommend asking at [discourse.paraview.org](http://discourse.paraview.org).
