# Catching opengl errors

**URL:** https://discourse.vtk.org/t/catching-opengl-errors/3945
**Category:** Support
**Created:** [August 10, 2020, 6:07pm UTC](https://discourse.vtk.org/t/catching-opengl-errors/3945 "2020-08-10T18:07:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mykolav](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mykolav/32/2177_2.png) [@mykolav](https://discourse.vtk.org/u/mykolav)
#### Post date: [August 10, 2020, 6:07pm UTC](https://discourse.vtk.org/t/catching-opengl-errors/3945/1 "2020-08-10T18:07:19Z")

</div>

Hi all, what would be the recommended way to handle errors that occur inside vtk, specifically connected with opengl errors?  
I’m creating a volume with dimensions that exceed my available VRAM, and I get the opengl and vtk error printed, but how can I catch them inside the code?  
I tried using `vtkObject->AddObserver(vtkCommand::ErrorEvent, vtkCommand)` and `vtkCommand::WarningEvent` on all elements of the pipeline, but that didn’t catch the error.

The printed error:

```auto
Failed to allocate 3D texture.1 OpenGL errors detected
  0 : (1285) Out of memory

ERROR: In .../VTK-9.0.1/Rendering/VolumeOpenGL2/vtkVolumeTexture.cxx, line 746
vtkVolumeTexture (0x5586665a3140): Texture 3D allocation failed! 

```

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [August 10, 2020, 7:54pm UTC](https://discourse.vtk.org/t/catching-opengl-errors/3945/2 "2020-08-10T19:54:21Z")

</div>

`vtkOutputWindow` (or its specific sub-class) invokes the `vtkCommand::ErrorEvent` when an error like the one you show is triggered. This means you’d have to provide an output window and set up observers for that instance.
