.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "extensions/sphinx-gallery/plot_06_failing.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_extensions_sphinx-gallery_plot_06_failing.py: 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. .. GENERATED FROM PYTHON SOURCE LINES 13-18 .. code-block:: Python # sphinx_gallery_failing_thumbnail = False import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 19-23 Setup Code ---------- This section runs successfully before the error. .. GENERATED FROM PYTHON SOURCE LINES 23-28 .. code-block:: Python data = [1, 2, 3, 4, 5] print(f"Data loaded: {data}") print(f"Length: {len(data)}") .. rst-class:: sphx-glr-script-out .. code-block:: none Data loaded: [1, 2, 3, 4, 5] Length: 5 .. GENERATED FROM PYTHON SOURCE LINES 29-34 Triggering an Error ------------------- The following code will raise a ``ValueError`` to demonstrate error handling and traceback display in sphinx-gallery. .. GENERATED FROM PYTHON SOURCE LINES 34-40 .. code-block:: Python # 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." ) .. rst-class:: sphx-glr-script-out .. code-block:: pytb 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 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. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.002 seconds) .. _sphx_glr_download_extensions_sphinx-gallery_plot_06_failing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_06_failing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_06_failing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_06_failing.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_