Skip to content

Commit e000297

Browse files
esp32/mphalport.c: Add info to OSError msg.
Change mp_printf(MP_PYTHON_PRINTER, ...) to mp_raise_msg_varg(&mp_type_OSError, ...) Co-Authored-By: Angus Gratton <205573+projectgus@users.noreply.github.com>
1 parent 4295f24 commit e000297

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ports/esp32/mphalport.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ 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+
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(code), func, line, file);
79+
#else
7780
// construct string object
7881
mp_obj_str_t *o_str = m_new_obj_maybe(mp_obj_str_t);
7982
if (o_str == NULL) {
@@ -84,12 +87,10 @@ void check_esp_err_(esp_err_t code, const char *func, const int line, const char
8487
o_str->data = (const byte *)esp_err_to_name(code); // esp_err_to_name ret's ptr to const str
8588
o_str->len = strlen((char *)o_str->data);
8689
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
9090
// raise
9191
mp_obj_t args[2] = { MP_OBJ_NEW_SMALL_INT(pcode), MP_OBJ_FROM_PTR(o_str)};
9292
nlr_raise(mp_obj_exception_make_new(&mp_type_OSError, 2, 0, args));
93+
#endif
9394
}
9495
}
9596

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