Note
Go to the end to download the full example code.
Error Output#
This example intentionally raises an exception to demonstrate how sphinx-gallery displays error tracebacks in the documentation.
Warning
This example is expected to fail. The error output below shows how sphinx-gallery renders Python exceptions.
# sphinx_gallery_failing_thumbnail = False
import matplotlib.pyplot as plt
Setup Code#
This section runs successfully before the error.
data = [1, 2, 3, 4, 5]
print(f"Data loaded: {data}")
print(f"Length: {len(data)}")
Data loaded: [1, 2, 3, 4, 5]
Length: 5
Triggering an Error#
The following code will raise a ValueError to demonstrate
error handling and traceback display in sphinx-gallery.
# This will raise an error
raise ValueError(
"This is an intentional error to demonstrate sphinx-gallery's "
"error handling. The traceback below shows how failures are displayed."
)
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinx-breeze-theme/checkouts/stable/docs/_gallery/plot_06_failing.py", line 36, in <module>
raise ValueError(
...<2 lines>...
)
ValueError: This is an intentional error to demonstrate sphinx-gallery's error handling. The traceback below shows how failures are displayed.
Total running time of the script: (0 minutes 0.002 seconds)