nrf: Aligning with upstream the use of nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, ...)
This commit is contained in:
parent
795116b432
commit
4468731e3d
@ -125,7 +125,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
|
|||||||
pin_obj = mp_call_function_1(MP_STATE_PORT(pin_class_mapper), user_obj);
|
pin_obj = mp_call_function_1(MP_STATE_PORT(pin_class_mapper), user_obj);
|
||||||
if (pin_obj != mp_const_none) {
|
if (pin_obj != mp_const_none) {
|
||||||
if (!MP_OBJ_IS_TYPE(pin_obj, &pin_type)) {
|
if (!MP_OBJ_IS_TYPE(pin_obj, &pin_type)) {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Pin.mapper didn't return a Pin object"));
|
mp_raise_ValueError("Pin.mapper didn't return a Pin object");
|
||||||
}
|
}
|
||||||
if (pin_class_debug) {
|
if (pin_class_debug) {
|
||||||
printf("Pin.mapper maps ");
|
printf("Pin.mapper maps ");
|
||||||
|
@ -287,7 +287,7 @@ STATIC mp_obj_t microbit_music_stop(mp_uint_t n_args, const mp_obj_t *args) {
|
|||||||
#ifdef MICROPY_HW_MUSIC_PIN
|
#ifdef MICROPY_HW_MUSIC_PIN
|
||||||
pin = &MICROPY_HW_MUSIC_PIN;
|
pin = &MICROPY_HW_MUSIC_PIN;
|
||||||
#else
|
#else
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
|
mp_raise_ValueError("pin parameter not given");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pin = (pin_obj_t *)args[0];
|
pin = (pin_obj_t *)args[0];
|
||||||
@ -340,7 +340,7 @@ STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_args,
|
|||||||
#ifdef MICROPY_HW_MUSIC_PIN
|
#ifdef MICROPY_HW_MUSIC_PIN
|
||||||
pin = &MICROPY_HW_MUSIC_PIN;
|
pin = &MICROPY_HW_MUSIC_PIN;
|
||||||
#else
|
#else
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
|
mp_raise_ValueError("pin parameter not given");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pin = (pin_obj_t *)args[1].u_obj;
|
pin = (pin_obj_t *)args[1].u_obj;
|
||||||
@ -395,7 +395,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args,
|
|||||||
#ifdef MICROPY_HW_MUSIC_PIN
|
#ifdef MICROPY_HW_MUSIC_PIN
|
||||||
pin = &MICROPY_HW_MUSIC_PIN;
|
pin = &MICROPY_HW_MUSIC_PIN;
|
||||||
#else
|
#else
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
|
mp_raise_ValueError("pin parameter not given");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pin = (pin_obj_t *)args[2].u_obj;
|
pin = (pin_obj_t *)args[2].u_obj;
|
||||||
@ -411,7 +411,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args,
|
|||||||
//TODO: pwm_release(pin->name);
|
//TODO: pwm_release(pin->name);
|
||||||
} else if (pwm_set_period_us(1000000/frequency)) {
|
} else if (pwm_set_period_us(1000000/frequency)) {
|
||||||
pwm_release(pin->pin); // TODO: remove pin setting.
|
pwm_release(pin->pin); // TODO: remove pin setting.
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid pitch"));
|
mp_raise_ValueError("invalid pitch");
|
||||||
}
|
}
|
||||||
if (duration >= 0) {
|
if (duration >= 0) {
|
||||||
// use async machinery to stop the pitch after the duration
|
// use async machinery to stop the pitch after the duration
|
||||||
|
@ -121,7 +121,7 @@ STATIC mp_obj_t os_dupterm(mp_uint_t n_args, const mp_obj_t *args) {
|
|||||||
} else if (mp_obj_get_type(args[0]) == &machine_hard_uart_type) {
|
} else if (mp_obj_get_type(args[0]) == &machine_hard_uart_type) {
|
||||||
MP_STATE_PORT(pyb_stdio_uart) = args[0];
|
MP_STATE_PORT(pyb_stdio_uart) = args[0];
|
||||||
} else {
|
} else {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "need a UART object"));
|
mp_raise_ValueError("need a UART object");
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user