circuitpython/docs/library/errno.rst

33 lines
851 B
ReStructuredText
Raw Normal View History

:mod:`errno` -- system error codes
2017-07-02 17:55:09 -04:00
===================================
.. module:: errno
2017-07-02 17:55:09 -04:00
:synopsis: system error codes
|see_cpython_module| :mod:`cpython:errno`.
2017-07-02 17:55:09 -04:00
This module provides access to symbolic error codes for `OSError` exception.
Constants
---------
.. data:: EEXIST, EAGAIN, etc.
Error codes, based on ANSI C/POSIX standard. All error codes start with
"E". Errors are usually accessible as ``exc.args[0]``
where ``exc`` is an instance of `OSError`. Usage example::
2017-07-02 17:55:09 -04:00
try:
os.mkdir("my_dir")
2017-07-02 17:55:09 -04:00
except OSError as exc:
if exc.args[0] == errno.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(errno.errorcode[uerrno.EEXIST])
2017-07-02 17:55:09 -04:00
EEXIST