# How to silently handle warnings and error messages from vtk functions / classes

**URL:** https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670
**Category:** Development
**Created:** [June 6, 2022, 8:58pm UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670 "2022-06-06T20:58:07Z")
**Posts on this page:** 6
**Page:** 2

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [June 13, 2022, 7:15am UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670/21 "2022-06-13T07:15:51Z")

</div>

> [@BlueKnight7](#):
>
> In essence, writing a subclass is basically fixing the problem that the developers created by not having the function make the right checks to begin with.

This is an easy fix. Just fix it ? 🙂

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [June 13, 2022, 1:18pm UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670/22 "2022-06-13T13:18:11Z")

</div>

Just fix it. That’s easy for you to say.

I’ve looked at the code and can’t come up with anything because of all the inheritance and other slight of hand that takes place.

For instance, I’ve discovered that vtkIntersectionPolyDataFilter is a class that vtkBooleanOperationPolyDataFilter uses where the 1st error occurs. I’ve traced this to the SplitSecondOutputOn function call. But, I can’t find that function anywhere in the source code; so, I can’t see where or how the return value is set or otherwise interpreted. I’m stuck.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [June 13, 2022, 11:30pm UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670/23 "2022-06-13T23:30:56Z")

</div>

> [@BlueKnight7](#):
>
> Just fix it. That’s easy for you to say.

I think @mwestphal was saying that while it should be fixed it won’t be so simple in practice.

> [@BlueKnight7](#):
>
> I can’t find that function anywhere in the source code; so, I can’t see where or how the return value is set or otherwise interpreted. I’m stuck.

It’s because macros are used in VTK which expand to functions

```auto
  vtkGetMacro(SplitSecondOutput, vtkTypeBool);
  vtkSetMacro(SplitSecondOutput, vtkTypeBool);
  vtkBooleanMacro(SplitSecondOutput, vtkTypeBool);

```

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [June 14, 2022, 12:39am UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670/24 "2022-06-14T00:39:31Z")

</div>

Okay, I understand about the macros; these weren’t as complicated as I thought. I see where the names were “expanded” in this case.

So, I thought vtkBooleanOperationPolyDataFilter invoking vtkBooleanOperationPolyDataFilter’s SplitSecondOutputOn function, which just sets a boolean to true, was causing vtkBooleanOperationPolyDataFilter’s RequestData function to be called, but it is not. Must be the Update call.

This leads to the next question, which I hope makes sense. Can an Update be triggered in the pipeline without an explicit call to do so? (Not knowing about all of the inheritance makes me wonder about this.)

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [June 14, 2022, 9:01am UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670/25 "2022-06-14T09:01:47Z")

</div>

> Can an Update be triggered in the pipeline without an explicit call to do so?

Yes. For example, a vtkRenderWindow::Render() method has the side effect of bringing the actor’s mapper up to date, which typically means updating the visualization pipeline.

---

<div class="post-metadata">

### Author: ![whereismymoney](https://discourse.vtk.org/user_avatar/discourse.vtk.org/whereismymoney/32/6859_2.png) [@whereismymoney](https://discourse.vtk.org/u/whereismymoney)
#### Post date: [February 21, 2024, 5:44am UTC](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670/26 "2024-02-21T05:44:38Z")

</div>

Here is one approach:

```auto
// Redirect error messages to a file
vtkSmartPointer<vtkFileOutputWindow> fow = vtkSmartPointer<vtkFileOutputWindow>::New();
fow->SetFileName("testfile.txt");
vtkOutputWindow::SetInstance(fow);

```

Then after a difficult operation (in my case, vtkArrayCalculator), you can check testfile.txt to see if it got larger.

[Previous page](https://discourse.vtk.org/t/how-to-silently-handle-warnings-and-error-messages-from-vtk-functions-classes/8670.md?page=1)
