Skip to content

Commit 008d306

Browse files
committed
esp32/mphalport.c: Add info to OSError msg.
Change mp_printf(MP_PYTHON_PRINTER, ...) to mp_raise_msg_varg(&mp_type_OSError, ...) Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
1 parent 4295f24 commit 008d306

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ports/esp32/mphalport.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ void check_esp_err_(esp_err_t code, const char *func, const int line, const char
7474
pcode = MP_EOPNOTSUPP;
7575
break;
7676
}
77+
#if MICROPY_ERROR_REPORTING > MICROPY_ERROR_REPORTING_NORMAL
78+
char err_msg[64];
79+
mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("%d, 0x%04X, '%s'" " in function '%s' at line %d in file '%s'"), pcode, code, (const char *)esp_err_to_name_r(code, err_msg, sizeof(err_msg)), func, line, file);
80+
#else
7781
// construct string object
7882
mp_obj_str_t *o_str = m_new_obj_maybe(mp_obj_str_t);
7983
if (o_str == NULL) {
@@ -84,12 +88,10 @@ void check_esp_err_(esp_err_t code, const char *func, const int line, const char
8488
o_str->data = (const byte *)esp_err_to_name(code); // esp_err_to_name ret's ptr to const str
8589
o_str->len = strlen((char *)o_str->data);
8690
o_str->hash = qstr_compute_hash(o_str->data, o_str->len);
87-
#if MICROPY_ERROR_REPORTING > MICROPY_ERROR_REPORTING_NORMAL
88-
mp_printf(MP_PYTHON_PRINTER, "Exception in function '%s' at line %d in file '%s'\n", func, line, file);
89-
#endif
9091
// raise
9192
mp_obj_t args[2] = { MP_OBJ_NEW_SMALL_INT(pcode), MP_OBJ_FROM_PTR(o_str)};
9293
nlr_raise(mp_obj_exception_make_new(&mp_type_OSError, 2, 0, args));
94+
#endif
9395
}
9496
}
9597

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy