File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,20 @@ const mp_obj_module_t mp_module_uerrno = {
100100};
101101
102102qstr mp_errno_to_str (mp_obj_t errno_val ) {
103+ // For commonly encountered errors, return human readable strings
104+ if (MP_OBJ_IS_SMALL_INT (errno_val )) {
105+ switch (MP_OBJ_SMALL_INT_VALUE (errno_val )) {
106+ case EPERM : return MP_QSTR_Permission_space_denied ;
107+ case ENOENT : return MP_QSTR_No_space_such_space_file_slash_directory ;
108+ case EIO : return MP_QSTR_Input_slash_output_space_error ;
109+ case EACCES : return MP_QSTR_Permission_space_denied ;
110+ case EEXIST : return MP_QSTR_File_space_exists ;
111+ case ENODEV : return MP_QSTR_Unsupported_space_operation ;
112+ case EINVAL : return MP_QSTR_Invalid_space_argument ;
113+ }
114+ }
115+
116+ // Otherwise, return the Exxxx string for that error code
103117 #if MICROPY_PY_UERRNO_ERRORCODE
104118 // We have the errorcode dict so can do a lookup using the hash map
105119 mp_map_elem_t * elem = mp_map_lookup ((mp_map_t * )& errorcode_dict .map , errno_val , MP_MAP_LOOKUP );
You can’t perform that action at this time.
0 commit comments