{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden" }, "source": [ "This notebook is part of the `nbsphinx` documentation: http://nbsphinx.readthedocs.io/." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Ignoring Errors on a Per-Cell Basis\n", "\n", "Instead of ignoring errors for all notebooks or for some selected notebooks (see [the previous notebook](allow-errors.ipynb)), you can be more fine-grained and just allow errors on certain code cells by tagging them with the `raises-exception` tag." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "'no problem'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following code cell has the `raises-exception` tag." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "raises-exception" ] }, "outputs": [], "source": [ "problem" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following code cell is executed even though the previous cell raised an exception." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "'no problem'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "Note\n", "\n", "The behavior of the `raises-exception` tag doesn't match its name.\n", "While it does *allow* exceptions,\n", "it does not check if an exception is actually raised!\n", "\n", "This will hopefully be fixed at some point,\n", "see https://github.com/jupyter/nbconvert/issues/730.\n", "\n", "
" ] } ], "metadata": { "celltoolbar": "Tags", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4+" } }, "nbformat": 4, "nbformat_minor": 4 }