Skip to content

Commit 38eebf6

Browse files
committed
Use :class: role
1 parent 31c6e4f commit 38eebf6

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

src/doc/en/developer/coding_in_python.rst

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -478,35 +478,28 @@ A method or a function accepts input described in the ``INPUT`` block of
478478
handled by the code, then it may raise an exception. The following aims to
479479
guide you in choosing from the most relevant exceptions to Sage. Raise
480480

481-
- `TypeError <https://docs.python.org/3/library/exceptions.html#TypeError>`_:
482-
if the input belongs to a class of objects that are not supported by the
483-
method. For example, a method works only with monic polynomials over a
484-
finite field, but a polynomial over rationals was given.
485-
486-
- `ValueError <https://docs.python.org/3/library/exceptions.html#ValueError>`_:
487-
if the input has a value not supported by the method. For example, the above
488-
method was given a non-monic polynomial.
489-
490-
- `ArithmeticError
491-
<https://docs.python.org/3/library/exceptions.html#ArithmeticError>`_: if the
492-
method performs an arithmetic operation (sum, product, quotient, and the
493-
like) but the input is not appropriate.
494-
495-
- `ZeroDivisionError
496-
<https://docs.python.org/3/library/exceptions.html#ZeroDivisionError>`_: if
497-
the method performs division but the input is zero. Note that for
498-
non-invertible input values, ``ArithmeticError`` is more appropriate. As
499-
derived from ``ArithmeticError``, ``ZeroDivisionError`` can be caught as
500-
``ArithmeticError``.
501-
502-
- `NotImplementedError
503-
<https://docs.python.org/3/library/exceptions.html#NotImplementedError>`_: if
504-
the input is for a feature not yet implemented by the method. Note that
505-
``NotImplementedError`` is derived from ``RuntimeError``.
506-
507-
If no specific error seems to apply for your situation, `RuntimeError
508-
<https://docs.python.org/3/library/exceptions.html#RuntimeError>`_ can be used.
509-
In all cases, the string associated with the exception should describe the
481+
- :class:`TypeError`: if the input belongs to a class of objects that are not
482+
supported by the method. For example, a method works only with monic
483+
polynomials over a finite field, but a polynomial over rationals was given.
484+
485+
- :class:`ValueError`: if the input has a value not supported by the method.
486+
For example, the above method was given a non-monic polynomial.
487+
488+
- :class:`ArithmeticError`: if the method performs an arithmetic operation
489+
(sum, product, quotient, and the like) but the input is not appropriate.
490+
491+
- :class:`ZeroDivisionError`: if the method performs division but the input is
492+
zero. Note that for non-invertible input values, :class:`ArithmeticError` is
493+
more appropriate. As derived from :class:`ArithmeticError`,
494+
:class:`ZeroDivisionError` can be caught as :class:`ArithmeticError`.
495+
496+
- :class:`NotImplementedError`: if the input is for a feature not yet
497+
implemented by the method. Note that this exception is derived from
498+
:class:`RuntimeError`.
499+
500+
If no specific error seems to apply for your situation, :class:`RuntimeError`
501+
can be used. In all cases, the string associated with the exception should
502+
describe the
510503
details of what went wrong.
511504

512505

0 commit comments

Comments
 (0)