pyvista.core.utilities.VtkErrorCatcher

pyvista.core.utilities.VtkErrorCatcher#

class VtkErrorCatcher(
raise_errors: bool = False,
send_to_logging: bool = True,
emit_warnings: bool = False,
)[source]#

Context manager to temporarily catch VTK errors.

Parameters:
raise_errorsbool, default: False

Raise a pyvista.VTKExecutionError (a runtime error) when a VTK error is observed.

Changed in version 0.47: A pyvista.VTKExecutionError is now raised instead of a generic RuntimeError.

send_to_loggingbool, default: True

Determine whether VTK errors raised within the context should also be sent to logging.

emit_warningsbool, default: False

Emit a pyvista.VTKExecutionWarning (a runtime warning) when a VTK warning is observed.

Added in version 0.47.

Examples

Catch VTK errors using the context manager. This only sends to logging by default.

>>> import pyvista as pv
>>> with pv.VtkErrorCatcher() as error_catcher:
...     sphere = pv.Sphere()

Raise VTK errors as Python errors and emit VTK warnings as Python warnings.

>>> with pv.VtkErrorCatcher(
...     raise_errors=True, emit_warnings=True
... ) as error_catcher:
...     sphere = pv.Sphere()

Methods#

Attributes#

VtkErrorCatcher.error_events

List of VTK error events observed.

VtkErrorCatcher.events

List of all VTK warning and error events observed.

VtkErrorCatcher.warning_events

List of VTK error events observed.