2021-08-12 04:59:29 +01:00
|
|
|
:mod:`errno` -- system error codes
|
|
|
|
==================================
|
2017-07-02 22:55:09 +01:00
|
|
|
|
2021-08-12 04:59:29 +01:00
|
|
|
.. module:: errno
|
2017-07-02 22:55:09 +01:00
|
|
|
:synopsis: system error codes
|
|
|
|
|
|
|
|
|see_cpython_module| :mod:`python:errno`.
|
|
|
|
|
|
|
|
This module provides access to symbolic error codes for `OSError` exception.
|
2020-06-04 02:38:45 +01:00
|
|
|
A particular inventory of codes depends on :term:`MicroPython port`.
|
2017-07-02 22:55:09 +01:00
|
|
|
|
|
|
|
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
|
2021-04-20 08:11:13 +01:00
|
|
|
:term:`MicroPython port`. Errors are usually accessible as ``exc.errno``
|
2017-12-03 13:50:37 +00:00
|
|
|
where ``exc`` is an instance of `OSError`. Usage example::
|
2017-07-02 22:55:09 +01:00
|
|
|
|
|
|
|
try:
|
2021-08-12 04:59:29 +01:00
|
|
|
os.mkdir("my_dir")
|
2017-07-02 22:55:09 +01:00
|
|
|
except OSError as exc:
|
2021-08-12 04:59:29 +01:00
|
|
|
if exc.errno == errno.EEXIST:
|
2017-07-02 22:55:09 +01:00
|
|
|
print("Directory already exists")
|
|
|
|
|
|
|
|
.. data:: errorcode
|
|
|
|
|
|
|
|
Dictionary mapping numeric error codes to strings with symbolic error
|
|
|
|
code (see above)::
|
|
|
|
|
2021-08-12 04:59:29 +01:00
|
|
|
>>> print(errno.errorcode[errno.EEXIST])
|
2017-07-02 22:55:09 +01:00
|
|
|
EEXIST
|