Skip to content

Commit ffb13cc

Browse files
committed
docs/uerrno: Document "uerrno" module.
1 parent 4f23c5d commit ffb13cc

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

docs/library/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ it will fallback to loading the built-in ``ujson`` module.
7777
sys.rst
7878
ubinascii.rst
7979
ucollections.rst
80+
uerrno.rst
8081
uhashlib.rst
8182
uheapq.rst
8283
uio.rst
@@ -102,6 +103,7 @@ it will fallback to loading the built-in ``ujson`` module.
102103
sys.rst
103104
ubinascii.rst
104105
ucollections.rst
106+
uerrno.rst
105107
uhashlib.rst
106108
uheapq.rst
107109
uio.rst
@@ -144,6 +146,7 @@ it will fallback to loading the built-in ``ujson`` module.
144146
sys.rst
145147
ubinascii.rst
146148
ucollections.rst
149+
uerrno.rst
147150
uhashlib.rst
148151
uheapq.rst
149152
uio.rst

docs/library/uerrno.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
:mod:`uerrno` -- system error codes
2+
===================================
3+
4+
.. module:: uerrno
5+
:synopsis: system error codes
6+
7+
|see_cpython_module| :mod:`python:errno`.
8+
9+
This module provides access to symbolic error codes for `OSError` exception.
10+
A particular inventory of codes depends on `MicroPython port`.
11+
12+
Constants
13+
---------
14+
15+
.. data:: EEXIST, EAGAIN, etc.
16+
17+
Error codes, based on ANSI C/POSIX standard. All error codes start with
18+
"E". As mentioned above, inventory of the codes depends on
19+
`MicroPython port`. Errors are usually accessible as ``exc.args[0]``
20+
where `exc` is an instance of `OSError`. Usage example::
21+
22+
try:
23+
uos.mkdir("my_dir")
24+
except OSError as exc:
25+
if exc.args[0] == uerrno.EEXIST:
26+
print("Directory already exists")
27+
28+
.. data:: errorcode
29+
30+
Dictionary mapping numeric error codes to strings with symbolic error
31+
code (see above)::
32+
33+
>>> print(uerrno.errorcode[uerrno.EEXIST])
34+
EEXIST

0 commit comments

Comments
 (0)