summaryrefslogtreecommitdiffstatshomepage
path: root/py/mperrno.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-05-12 13:20:40 +0100
committerDamien George <damien.p.george@gmail.com>2016-05-12 13:20:40 +0100
commitd45e5f8c357d13e66aeac644e2b5ead8c734025f (patch)
treec6d9ab833d5a9b528e1b3cb05c47a31b2331a4c2 /py/mperrno.h
parent47bf6ba61a2f332b44471badd1e50658ae7d264c (diff)
downloadmicropython-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.h6
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__