summaryrefslogtreecommitdiffstatshomepage
path: root/docs/library/uerrno.rst
blob: 0cdcc844877e771f938a074c04fa5e3f7ccda6f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
:mod:`uerrno` -- system error codes
===================================

.. module:: uerrno
   :synopsis: system error codes

|see_cpython_module| :mod:`python:errno`.

This module provides access to symbolic error codes for `OSError` exception.
A particular inventory of codes depends on `MicroPython port`.

Constants
---------

.. data:: EEXIST, EAGAIN, etc.

    Error codes, based on ANSI C/POSIX standard. All error codes start with
    "E". As mentioned above, inventory of the codes depends on
    `MicroPython port`. Errors are usually accessible as ``exc.args[0]``
    where `exc` is an instance of `OSError`. Usage example::

        try:
            uos.mkdir("my_dir")
        except OSError as exc:
            if exc.args[0] == uerrno.EEXIST:
                print("Directory already exists")

.. data:: errorcode

    Dictionary mapping numeric error codes to strings with symbolic error
    code (see above)::

        >>> print(uerrno.errorcode[uerrno.EEXIST])
        EEXIST