Skip to content

Commit 8426773

Browse files
committed
Standardize more error messages to save space
1 parent 6311f13 commit 8426773

File tree

12 files changed

+45
-70
lines changed

12 files changed

+45
-70
lines changed

locale/circuitpython.pot

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ msgstr ""
497497
#: ports/nrf/common-hal/countio/Counter.c
498498
#: ports/nrf/common-hal/pulseio/PulseIn.c
499499
#: ports/nrf/common-hal/rotaryio/IncrementalEncoder.c
500-
#: shared-bindings/pwmio/PWMOut.c
501500
msgid "All channels in use"
502501
msgstr ""
503502

@@ -520,13 +519,11 @@ msgid "All sync event channels in use"
520519
msgstr ""
521520

522521
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c
523-
#: shared-bindings/pwmio/PWMOut.c
524522
msgid "All timers for this pin are in use"
525523
msgstr ""
526524

527525
#: ports/atmel-samd/common-hal/_pew/PewPew.c
528526
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
529-
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
530527
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
531528
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
532529
#: ports/cxd56/common-hal/pulseio/PulseOut.c
@@ -537,7 +534,7 @@ msgstr ""
537534
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
538535
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
539536
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
540-
#: ports/stm/peripherals/timers.c shared-bindings/pwmio/PWMOut.c
537+
#: ports/stm/peripherals/timers.c
541538
msgid "All timers in use"
542539
msgstr ""
543540

@@ -776,12 +773,6 @@ msgstr ""
776773
msgid "Cannot remount '/' when visible via USB."
777774
msgstr ""
778775

779-
#: ports/atmel-samd/common-hal/microcontroller/__init__.c
780-
#: ports/cxd56/common-hal/microcontroller/__init__.c
781-
#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c
782-
msgid "Cannot reset into bootloader because no bootloader is present"
783-
msgstr ""
784-
785776
#: ports/espressif/common-hal/socketpool/Socket.c
786777
msgid "Cannot set socket options"
787778
msgstr ""
@@ -799,10 +790,6 @@ msgstr ""
799790
msgid "Cannot subclass slice"
800791
msgstr ""
801792

802-
#: shared-bindings/pwmio/PWMOut.c
803-
msgid "Cannot vary frequency on a timer that is already in use"
804-
msgstr ""
805-
806793
#: ports/nrf/common-hal/alarm/pin/PinAlarm.c
807794
msgid "Cannot wake on pin edge, only level"
808795
msgstr ""
@@ -845,10 +832,6 @@ msgstr ""
845832
msgid "Could not set address"
846833
msgstr ""
847834

848-
#: shared-bindings/pwmio/PWMOut.c
849-
msgid "Could not start PWM"
850-
msgstr ""
851-
852835
#: ports/stm/common-hal/busio/UART.c
853836
msgid "Could not start interrupt, RX busy"
854837
msgstr ""
@@ -940,16 +923,6 @@ msgstr ""
940923
msgid "ESP-IDF memory allocation failed"
941924
msgstr ""
942925

943-
#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c
944-
#: ports/atmel-samd/common-hal/countio/Counter.c
945-
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
946-
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
947-
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
948-
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
949-
#: ports/cxd56/common-hal/pulseio/PulseIn.c
950-
msgid "EXTINT channel already in use"
951-
msgstr ""
952-
953926
#: extmod/modre.c
954927
msgid "Error in regex"
955928
msgstr ""
@@ -1082,10 +1055,6 @@ msgid ""
10821055
"Frequency must be 24, 150, 396, 450, 528, 600, 720, 816, 912, 960 or 1008 Mhz"
10831056
msgstr ""
10841057

1085-
#: shared-bindings/pwmio/PWMOut.c
1086-
msgid "Frequency must match existing PWMOut using this timer"
1087-
msgstr ""
1088-
10891058
#: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c
10901059
#: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c
10911060
msgid "Function requires lock"
@@ -1195,7 +1164,7 @@ msgid "Internal define error"
11951164
msgstr ""
11961165

11971166
#: ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c
1198-
#: shared-module/os/getenv.c
1167+
#: shared-bindings/pwmio/PWMOut.c shared-module/os/getenv.c
11991168
msgid "Internal error"
12001169
msgstr ""
12011170

@@ -1204,6 +1173,16 @@ msgstr ""
12041173
msgid "Internal error #%d"
12051174
msgstr ""
12061175

1176+
#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c
1177+
#: ports/atmel-samd/common-hal/countio/Counter.c
1178+
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
1179+
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
1180+
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
1181+
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
1182+
#: ports/cxd56/common-hal/pulseio/PulseIn.c shared-bindings/pwmio/PWMOut.c
1183+
msgid "Internal resource(s) in use"
1184+
msgstr ""
1185+
12071186
#: supervisor/shared/safe_mode.c
12081187
msgid "Internal watchdog timer expired."
12091188
msgstr ""
@@ -1221,7 +1200,7 @@ msgstr ""
12211200
#: ports/raspberrypi/bindings/picodvi/Framebuffer.c
12221201
#: ports/raspberrypi/common-hal/picodvi/Framebuffer.c py/argcheck.c
12231202
#: shared-bindings/digitalio/DigitalInOut.c
1224-
#: shared-bindings/epaperdisplay/EPaperDisplay.c
1203+
#: shared-bindings/epaperdisplay/EPaperDisplay.c shared-bindings/pwmio/PWMOut.c
12251204
msgid "Invalid %q"
12261205
msgstr ""
12271206

@@ -1457,8 +1436,10 @@ msgstr ""
14571436
msgid "No IP"
14581437
msgstr ""
14591438

1460-
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
1461-
msgid "No available clocks"
1439+
#: ports/atmel-samd/common-hal/microcontroller/__init__.c
1440+
#: ports/cxd56/common-hal/microcontroller/__init__.c
1441+
#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c
1442+
msgid "No bootloader present"
14621443
msgstr ""
14631444

14641445
#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c
@@ -1681,11 +1662,6 @@ msgstr ""
16811662
msgid "Out-buffer elements must be <= 4 bytes long"
16821663
msgstr ""
16831664

1684-
#: shared-bindings/pwmio/PWMOut.c
1685-
msgid ""
1686-
"PWM frequency not writable when variable_frequency is False on construction."
1687-
msgstr ""
1688-
16891665
#: ports/stm/common-hal/pwmio/PWMOut.c
16901666
msgid "PWM restart"
16911667
msgstr ""
@@ -1731,11 +1707,6 @@ msgstr ""
17311707
msgid "Pin must be on PWM Channel B"
17321708
msgstr ""
17331709

1734-
#: ports/atmel-samd/common-hal/countio/Counter.c
1735-
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
1736-
msgid "Pin must support hardware interrupts"
1737-
msgstr ""
1738-
17391710
#: shared-bindings/rgbmatrix/RGBMatrix.c
17401711
#, c-format
17411712
msgid ""

ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static void pinalarm_set_alarms_light(size_t n_alarms, const mp_obj_t *alarms) {
235235
case PINALARM_ERR_NOEXTINT:
236236
raise_ValueError_invalid_pin();
237237
case PINALARM_ERR_NOCHANNEL:
238-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
238+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
239239
default:
240240
mp_raise_RuntimeError(MP_ERROR_TEXT("Unknown reason."));
241241
}

ports/atmel-samd/common-hal/countio/Counter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include "common-hal/countio/Counter.h"
33
#include "shared-bindings/countio/Counter.h"
4+
#include "shared-bindings/microcontroller/Pin.h"
45

56
#include "atmel_start_pins.h"
67

@@ -11,13 +12,13 @@
1112
void common_hal_countio_counter_construct(countio_counter_obj_t *self,
1213
const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) {
1314
if (!pin->has_extint) {
14-
mp_raise_RuntimeError(MP_ERROR_TEXT("Pin must support hardware interrupts"));
15+
raise_ValueError_invalid_pin();
1516
}
1617

1718

1819
if (eic_get_enable()) {
1920
if (!eic_channel_free(pin->extint_channel)) {
20-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
21+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
2122
}
2223
} else {
2324
turn_on_external_interrupt_controller();

ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
295295
#ifdef SAM_D5X_E5X
296296
((EIC->INTENSET.bit.EXTINT & mask) != 0 || (EIC->EVCTRL.bit.EXTINTEO & mask) != 0)) {
297297
#endif
298-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
298+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
299299
}
300300

301301
uint8_t timer_index = find_free_timer();
302302
if (timer_index == 0xff) {
303-
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
303+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
304304
}
305305
Tc *tc = tc_insts[timer_index];
306306

@@ -329,7 +329,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
329329
frequencyin_samd51_start_dpll();
330330
if (dpll_gclk == 0xff && !clock_get_enabled(0, GCLK_SOURCE_DPLL1)) {
331331
common_hal_frequencyio_frequencyin_deinit(self);
332-
mp_raise_RuntimeError(MP_ERROR_TEXT("No available clocks"));
332+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
333333
}
334334
set_timer_handler(timer_index, dpll_gclk, TC_HANDLER_NO_INTERRUPT);
335335
turn_on_clocks(true, timer_index, dpll_gclk);
@@ -399,7 +399,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
399399
reference_tc = find_free_timer();
400400
if (reference_tc == 0xff) {
401401
common_hal_frequencyio_frequencyin_deinit(self);
402-
mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use"));
402+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
403403
}
404404
frequencyin_reference_tc_init();
405405
}

ports/atmel-samd/common-hal/microcontroller/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void common_hal_mcu_enable_interrupts(void) {
6464
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
6565
if ((runmode == RUNMODE_BOOTLOADER) || (runmode == RUNMODE_UF2)) {
6666
if (!bootloader_available()) {
67-
mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present"));
67+
mp_raise_ValueError(MP_ERROR_TEXT("No bootloader present"));
6868
}
6969
// Pretend to be the first of the two reset presses needed to enter the
7070
// bootloader. That way one reset will end in the bootloader.

ports/atmel-samd/common-hal/ps2io/Ps2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self,
248248
mp_arg_error_invalid(MP_QSTR_clock_pin);
249249
}
250250
if (eic_get_enable() && !eic_channel_free(clock_pin->extint_channel)) {
251-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
251+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
252252
}
253253

254254
clk_hi(self);

ports/atmel-samd/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
155155
raise_ValueError_invalid_pin();
156156
}
157157
if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) {
158-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
158+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
159159
}
160160

161161
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t));

ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "common-hal/rotaryio/IncrementalEncoder.h"
28+
#include "shared-bindings/microcontroller/Pin.h"
2829
#include "shared-bindings/rotaryio/IncrementalEncoder.h"
2930
#include "shared-module/rotaryio/IncrementalEncoder.h"
3031

@@ -36,16 +37,19 @@
3637

3738
void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self,
3839
const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b) {
39-
if (!pin_a->has_extint || !pin_b->has_extint) {
40-
mp_raise_RuntimeError(MP_ERROR_TEXT("Pin must support hardware interrupts"));
40+
if (!pin_a->has_extint) {
41+
raise_ValueError_invalid_pin_name(MP_QSTR_pin_a);
42+
}
43+
if (!pin_b->has_extint) {
44+
raise_ValueError_invalid_pin_name(MP_QSTR_pin_b);
4145
}
4246

4347
// TODO: The SAMD51 has a peripheral dedicated to quadrature encoder debugging. Use it instead
4448
// of the external interrupt.
4549

4650
if (eic_get_enable()) {
4751
if (!eic_channel_free(pin_a->extint_channel) || !eic_channel_free(pin_b->extint_channel)) {
48-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
52+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
4953
}
5054
} else {
5155
turn_on_external_interrupt_controller();

ports/cxd56/common-hal/microcontroller/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void common_hal_mcu_enable_interrupts(void) {
7272

7373
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
7474
if (runmode == RUNMODE_BOOTLOADER) {
75-
mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present"));
75+
mp_raise_ValueError(MP_ERROR_TEXT("No bootloader present"));
7676
} else if (runmode == RUNMODE_SAFE_MODE) {
7777
safe_mode_on_next_reset(SAFE_MODE_PROGRAMMATIC);
7878
}

ports/cxd56/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
100100

101101
int irq = pulsein_set_config(self, true);
102102
if (irq < 0) {
103-
mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use"));
103+
mp_raise_RuntimeError(MP_ERROR_TEXT("Internal resource(s) in use"));
104104
} else {
105105
pulsein_objects[irq - CXD56_IRQ_EXDEVICE_0] = self;
106106
}

0 commit comments

Comments
 (0)