2017-07-02 17:55:09 -04:00
|
|
|
: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.
|
2020-06-03 21:38:45 -04:00
|
|
|
A particular inventory of codes depends on :term:`MicroPython port`.
|
2017-07-02 17:55:09 -04: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 03:11:13 -04:00
|
|
|
:term:`MicroPython port`. Errors are usually accessible as ``exc.errno``
|
2017-12-03 08:50:37 -05:00
|
|
|
where ``exc`` is an instance of `OSError`. Usage example::
|
2017-07-02 17:55:09 -04:00
|
|
|
|
|
|
|
try:
|
|
|
|
uos.mkdir("my_dir")
|
|
|
|
except OSError as exc:
|
2021-04-20 03:11:13 -04:00
|
|
|
if exc.errno == uerrno.EEXIST:
|
2017-07-02 17:55:09 -04:00
|
|
|
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
|