Skip to content

Commit 2bf5a94

Browse files
committed
stmhal: Make error messages more consistent across peripherals.
1 parent 48d867b commit 2bf5a94

File tree

12 files changed

+21
-21
lines changed

12 files changed

+21
-21
lines changed

stmhal/can.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ STATIC mp_obj_t pyb_can_init_helper(pyb_can_obj_t *self, mp_uint_t n_args, const
321321

322322
// init CAN (if it fails, it's because the port doesn't exist)
323323
if (!can_init(self)) {
324-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN port %d does not exist", self->can_id));
324+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN(%d) doesn't exist", self->can_id));
325325
}
326326

327327
return mp_const_none;
@@ -357,13 +357,13 @@ STATIC mp_obj_t pyb_can_make_new(const mp_obj_type_t *type, size_t n_args, size_
357357
can_idx = PYB_CAN_2;
358358
#endif
359359
} else {
360-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN(%s) does not exist", port));
360+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN(%s) doesn't exist", port));
361361
}
362362
} else {
363363
can_idx = mp_obj_get_int(args[0]);
364364
}
365365
if (can_idx < 1 || can_idx > MP_ARRAY_SIZE(MP_STATE_PORT(pyb_can_obj_all))) {
366-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN(%d) does not exist", can_idx));
366+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN(%d) doesn't exist", can_idx));
367367
}
368368

369369
pyb_can_obj_t *self;

stmhal/dac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ STATIC mp_obj_t pyb_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_
221221
} else if (pin == &pin_A5) {
222222
dac_id = 2;
223223
} else {
224-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin %q does not have DAC capabilities", pin->name));
224+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Pin(%q) doesn't have DAC capabilities", pin->name));
225225
}
226226
}
227227

@@ -237,7 +237,7 @@ STATIC mp_obj_t pyb_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_
237237
dac->dac_channel = DAC_CHANNEL_2;
238238
dac->tx_dma_descr = &dma_DAC_2_TX;
239239
} else {
240-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "DAC %d does not exist", dac_id));
240+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "DAC(%d) doesn't exist", dac_id));
241241
}
242242

243243
// configure the peripheral

stmhal/i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,14 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
626626
#endif
627627
} else {
628628
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
629-
"I2C(%s) does not exist", port));
629+
"I2C(%s) doesn't exist", port));
630630
}
631631
} else {
632632
i2c_id = mp_obj_get_int(args[0]);
633633
if (i2c_id < 1 || i2c_id > MP_ARRAY_SIZE(pyb_i2c_obj)
634634
|| pyb_i2c_obj[i2c_id - 1].i2c == NULL) {
635635
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
636-
"I2C(%d) does not exist", i2c_id));
636+
"I2C(%d) doesn't exist", i2c_id));
637637
}
638638
}
639639

stmhal/lcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ STATIC mp_obj_t pyb_lcd_make_new(const mp_obj_type_t *type, size_t n_args, size_
220220
lcd->pin_a0 = &pyb_pin_Y5;
221221
lcd->pin_bl = &pyb_pin_Y12;
222222
} else {
223-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LCD bus '%s' does not exist", lcd_id));
223+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LCD(%s) doesn't exist", lcd_id));
224224
}
225225

226226
// init the SPI bus

stmhal/led.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ STATIC mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_
299299

300300
// check led number
301301
if (!(1 <= led_id && led_id <= NUM_LEDS)) {
302-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LED(%d) does not exist", led_id));
302+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LED(%d) doesn't exist", led_id));
303303
}
304304

305305
// return static led object

stmhal/machine_i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,14 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
510510
#endif
511511
} else {
512512
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
513-
"I2C(%s) does not exist", port));
513+
"I2C(%s) doesn't exist", port));
514514
}
515515
} else {
516516
i2c_id = mp_obj_get_int(args[ARG_id].u_obj);
517517
if (i2c_id < 1 || i2c_id > MP_ARRAY_SIZE(machine_hard_i2c_obj)
518518
|| machine_hard_i2c_obj[i2c_id - 1].base.type == NULL) {
519519
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
520-
"I2C(%d) does not exist", i2c_id));
520+
"I2C(%d) doesn't exist", i2c_id));
521521
}
522522
}
523523

stmhal/pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
176176
return pin_obj;
177177
}
178178

179-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin '%s' not a valid pin identifier", mp_obj_str_get_str(user_obj)));
179+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Pin(%s) doesn't exist", mp_obj_str_get_str(user_obj)));
180180
}
181181

182182
/// \method __str__()

stmhal/servo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ STATIC mp_obj_t pyb_servo_make_new(const mp_obj_type_t *type, size_t n_args, siz
194194

195195
// check servo number
196196
if (!(0 <= servo_id && servo_id < PYB_SERVO_NUM)) {
197-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Servo %d does not exist", servo_id + 1));
197+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Servo(%d) doesn't exist", servo_id + 1));
198198
}
199199

200200
// get and init servo object

stmhal/spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ STATIC int spi_find(mp_obj_t id) {
182182
#endif
183183
}
184184
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
185-
"SPI(%s) does not exist", port));
185+
"SPI(%s) doesn't exist", port));
186186
} else {
187187
// given an integer id
188188
int spi_id = mp_obj_get_int(id);
@@ -191,7 +191,7 @@ STATIC int spi_find(mp_obj_t id) {
191191
return spi_id;
192192
}
193193
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
194-
"SPI(%d) does not exist", spi_id));
194+
"SPI(%d) doesn't exist", spi_id));
195195
}
196196
}
197197

stmhal/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, siz
702702
#if defined(TIM17)
703703
case 17: tim->tim.Instance = TIM17; tim->irqn = TIM1_TRG_COM_TIM17_IRQn; break;
704704
#endif
705-
default: nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Timer %d does not exist", tim->tim_id));
705+
default: nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Timer(%d) doesn't exist", tim->tim_id));
706706
}
707707

708708
// set the global variable for interrupt callbacks
@@ -896,7 +896,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
896896
const pin_obj_t *pin = pin_obj;
897897
const pin_af_obj_t *af = pin_find_af(pin, AF_FN_TIM, self->tim_id);
898898
if (af == NULL) {
899-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin %q doesn't have an af for TIM%d", pin->name, self->tim_id));
899+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Pin(%q) doesn't have an af for Timer(%d)", pin->name, self->tim_id));
900900
}
901901
// pin.init(mode=AF_PP, af=idx)
902902
const mp_obj_t args2[6] = {

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