diff --git a/doc/main/index.rst b/doc/main/index.rst index f711f5a..5b2df40 100644 --- a/doc/main/index.rst +++ b/doc/main/index.rst @@ -121,6 +121,7 @@ Pybricks Documentation micropython/builtins micropython/exceptions micropython/micropython + micropython/uerrno micropython/uio micropython/umath micropython/urandom diff --git a/doc/main/micropython/exceptions.rst b/doc/main/micropython/exceptions.rst index 09e1c1e..173824c 100644 --- a/doc/main/micropython/exceptions.rst +++ b/doc/main/micropython/exceptions.rst @@ -1,10 +1,6 @@ -Exceptions and error codes +Exceptions and errors ===================================================== - -List of all exceptions ----------------------- - This section lists all available exceptions in alphabetical order. .. autoclass:: ubuiltins.ArithmeticError @@ -55,11 +51,11 @@ This section lists all available exceptions in alphabetical order. .. autoclass:: ubuiltins.NotImplementedError :no-members: +.. _OSError: + .. autoclass:: ubuiltins.OSError :noindex: - See the `OSError`_ section for additional details. - .. autoclass:: ubuiltins.OverflowError :no-members: @@ -84,37 +80,6 @@ This section lists all available exceptions in alphabetical order. .. autoclass:: ubuiltins.ZeroDivisionError :no-members: -.. _OSError: - -Using ``OSError`` with :mod:`uerrno` ------------------------------------- - -The ``errno`` attribute of an ``OSError`` indicates why the exception was -raised. This attribute has one of the following values, which can be imported -from the ``uerrno`` module. See also :ref:`this example `. - -.. module:: uerrno - -.. autodata:: uerrno.EAGAIN - -.. autodata:: uerrno.EBUSY - -.. autodata:: uerrno.ECANCELED - -.. autodata:: uerrno.EINVAL - -.. autodata:: uerrno.EIO - -.. autodata:: uerrno.ENODEV - -.. autodata:: uerrno.EOPNOTSUPP - -.. autodata:: uerrno.EPERM - -.. autodata:: uerrno.ETIMEDOUT - -.. autodata:: uerrno.errorcode - Examples --------------------- diff --git a/doc/main/micropython/uerrno.rst b/doc/main/micropython/uerrno.rst new file mode 100644 index 0000000..ca57ff1 --- /dev/null +++ b/doc/main/micropython/uerrno.rst @@ -0,0 +1,28 @@ +:mod:`uerrno ` -- Error codes +============================================================ + +.. module:: uerrno + +The ``errno`` attribute of an :ref:`OSError ` indicates why this +exception was raised. This attribute has one of the following values. +See also :ref:`this example `. + +.. autodata:: uerrno.EAGAIN + +.. autodata:: uerrno.EBUSY + +.. autodata:: uerrno.ECANCELED + +.. autodata:: uerrno.EINVAL + +.. autodata:: uerrno.EIO + +.. autodata:: uerrno.ENODEV + +.. autodata:: uerrno.EOPNOTSUPP + +.. autodata:: uerrno.EPERM + +.. autodata:: uerrno.ETIMEDOUT + +.. autodata:: uerrno.errorcode diff --git a/src/ubuiltins/__init__.py b/src/ubuiltins/__init__.py index 2eda861..8738686 100644 --- a/src/ubuiltins/__init__.py +++ b/src/ubuiltins/__init__.py @@ -968,14 +968,16 @@ class NotImplementedError(RuntimeError): class OSError(Exception): """ This exception is raised by the firmware, which is - the Operating System that runs on the hub. For example, it + the Operating System that runs on the hub. + For :ref:`example `, it raises an ``OSError`` if you call ``Motor(Port.A)`` when there is no motor on port A. """ errno: _int """ - Specifies which kind of ``OSError`` occurred, as listed :ref:`here `. + Specifies which kind of ``OSError`` occurred, as listed in the + :mod:`uerrno` module. """