summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-02-04 13:32:39 -0500
committerDan Halbert <halbert@halwitz.org>2020-02-04 13:32:39 -0500
commit57b566e73614c74a9fc74cd2d2007d91cdb507db (patch)
tree46f302c21c5e243cb17997559b93bd6665289573 /py/runtime.c
parenta4ebd2f7c112dc5d185d198e28e00edabd395a84 (diff)
Include filename for 'No such file/directory', etc.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 48416bab2..cb174837c 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -29,10 +29,12 @@
#include <string.h>
#include <assert.h>
+
#include "extmod/vfs.h"
#include "py/parsenum.h"
#include "py/compile.h"
+#include "py/mperrno.h"
#include "py/objstr.h"
#include "py/objtuple.h"
#include "py/objtype.h"
@@ -1576,6 +1578,13 @@ NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_OSError, msg);
}
+NORETURN void mp_raise_OSError_errno_str(int errno_, const char *str) {
+ char decompressed[50];
+ const char *errno_str = mp_common_errno_to_str(MP_OBJ_NEW_SMALL_INT(errno_),
+ decompressed, sizeof(decompressed));
+ mp_raise_OSError_msg_varg(translate("[Errno %d] %s: %s"), errno_, errno_str, str);
+}
+
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);