summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial/errors.rst
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-03 23:10:20 (GMT)
committerGitHub <noreply@github.com>2022-01-03 23:10:20 (GMT)
commit0b3c3cbbaf2967cc17531d65ece0969b0d2a2079 (patch)
tree77938930a74fafeddb97ce2aaeac6ebaa54e9b70 /Doc/tutorial/errors.rst
parent8184a613b93d54416b954e667951cdf3d069cc13 (diff)
downloadcpython-0b3c3cbbaf2967cc17531d65ece0969b0d2a2079.zip
cpython-0b3c3cbbaf2967cc17531d65ece0969b0d2a2079.tar.gz
cpython-0b3c3cbbaf2967cc17531d65ece0969b0d2a2079.tar.bz2
bpo-34538: Remove Exception subclassing from tutorial (GH-30361)
Remove the bit about subclassing exceptions. Documentation PR can skip the NEWS label. Automerge-Triggered-By: GH:iritkatriel (cherry picked from commit 2db56130631255ca2eb504519430fb2f1fe789e9) Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Doc/tutorial/errors.rst')
-rw-r--r--Doc/tutorial/errors.rst36
1 files changed, 1 insertions, 35 deletions
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index f2490d6..3f09db2 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -329,41 +329,7 @@ be derived from the :exc:`Exception` class, either directly or indirectly.
Exception classes can be defined which do anything any other class can do, but
are usually kept simple, often only offering a number of attributes that allow
-information about the error to be extracted by handlers for the exception. When
-creating a module that can raise several distinct errors, a common practice is
-to create a base class for exceptions defined by that module, and subclass that
-to create specific exception classes for different error conditions::
-
- class Error(Exception):
- """Base class for exceptions in this module."""
- pass
-
- class InputError(Error):
- """Exception raised for errors in the input.
-
- Attributes:
- expression -- input expression in which the error occurred
- message -- explanation of the error
- """
-
- def __init__(self, expression, message):
- self.expression = expression
- self.message = message
-
- class TransitionError(Error):
- """Raised when an operation attempts a state transition that's not
- allowed.
-
- Attributes:
- previous -- state at beginning of transition
- next -- attempted new state
- message -- explanation of why the specific transition is not allowed
- """
-
- def __init__(self, previous, next, message):
- self.previous = previous
- self.next = next
- self.message = message
+information about the error to be extracted by handlers for the exception.
Most exceptions are defined with names that end in "Error", similar to the
naming of the standard exceptions.