diff options
author | Damien George <damien.p.george@gmail.com> | 2016-05-12 13:20:40 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-05-12 13:20:40 +0100 |
commit | d45e5f8c357d13e66aeac644e2b5ead8c734025f (patch) | |
tree | c6d9ab833d5a9b528e1b3cb05c47a31b2331a4c2 /py/mperrno.h | |
parent | 47bf6ba61a2f332b44471badd1e50658ae7d264c (diff) | |
download | micropython-d45e5f8c357d13e66aeac644e2b5ead8c734025f.tar.gz micropython-d45e5f8c357d13e66aeac644e2b5ead8c734025f.zip |
py: Add mp_errno_to_str() and use it to provide nicer OSError msgs.
If an OSError is raised with an integer argument, and that integer
corresponds to an errno, then the string for the errno is used as the
argument to the exception, instead of the integer. Only works if
the uerrno module is enabled.
Diffstat (limited to 'py/mperrno.h')
-rw-r--r-- | py/mperrno.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/mperrno.h b/py/mperrno.h index da541284c6..2dbb7b0a82 100644 --- a/py/mperrno.h +++ b/py/mperrno.h @@ -134,4 +134,10 @@ #endif +#if MICROPY_PY_UERRNO +mp_obj_t mp_errno_to_str(mp_obj_t errno_val); +#else +static inline mp_obj_t mp_errno_to_str(mp_obj_t errno_val) { return errno_val; } +#endif + #endif // __MICROPY_INCLUDED_PY_MPERRNO_H__ |