consolidate and shorten some error messages

This commit is contained in:
Dan Halbert 2023-08-19 12:14:58 -04:00
parent 7933bb0ebe
commit 10a022db87
9 changed files with 23 additions and 27 deletions

View File

@ -31,8 +31,8 @@ msgstr ""
#: supervisor/shared/safe_mode.c #: supervisor/shared/safe_mode.c
msgid "" msgid ""
"\n" "\n"
"Please file an issue with your program at https://github.com/adafruit/" "Please file an issue with your program at github.com/adafruit/circuitpython/"
"circuitpython/issues." "issues."
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c #: supervisor/shared/safe_mode.c
@ -633,11 +633,6 @@ msgstr ""
msgid "Buffer is not a bytearray." msgid "Buffer is not a bytearray."
msgstr "" msgstr ""
#: ports/cxd56/common-hal/camera/Camera.c shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Buffer is too small"
msgstr ""
#: ports/stm/common-hal/audiopwmio/PWMAudioOut.c #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c
#, c-format #, c-format
msgid "Buffer length %d too big. It must be less than %d" msgid "Buffer length %d too big. It must be less than %d"
@ -657,6 +652,12 @@ msgstr ""
msgid "Buffer too short by %d bytes" msgid "Buffer too short by %d bytes"
msgstr "" msgstr ""
#: ports/cxd56/common-hal/camera/Camera.c shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
#: shared-bindings/struct/__init__.c shared-module/struct/__init__.c
msgid "Buffer too small"
msgstr ""
#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c
msgid "Buffers must be same size" msgid "Buffers must be same size"
msgstr "" msgstr ""
@ -1786,6 +1787,10 @@ msgstr ""
msgid "Polygon needs at least 3 points" msgid "Polygon needs at least 3 points"
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c
msgid "Power dipped. Make sure you are providing enough power."
msgstr ""
#: shared-bindings/_bleio/Adapter.c #: shared-bindings/_bleio/Adapter.c
msgid "Prefix buffer must be on the heap" msgid "Prefix buffer must be on the heap"
msgstr "" msgstr ""
@ -2016,10 +2021,6 @@ msgstr ""
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30" msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
msgstr "" msgstr ""
#: supervisor/shared/safe_mode.c
msgid "The power dipped. Make sure you are providing enough power."
msgstr ""
#: shared-module/audiomixer/MixerVoice.c #: shared-module/audiomixer/MixerVoice.c
msgid "The sample's bits_per_sample does not match the mixer's" msgid "The sample's bits_per_sample does not match the mixer's"
msgstr "" msgstr ""
@ -2605,8 +2606,7 @@ msgstr ""
msgid "buffer slices must be of equal length" msgid "buffer slices must be of equal length"
msgstr "" msgstr ""
#: py/modstruct.c shared-bindings/struct/__init__.c #: py/modstruct.c shared-module/struct/__init__.c
#: shared-module/struct/__init__.c
msgid "buffer too small" msgid "buffer too small"
msgstr "" msgstr ""
@ -3863,10 +3863,6 @@ msgstr ""
msgid "pixel coordinates out of bounds" msgid "pixel coordinates out of bounds"
msgstr "" msgstr ""
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter"
msgstr ""
#: extmod/vfs_posix_file.c #: extmod/vfs_posix_file.c
msgid "poll on file not available on win32" msgid "poll on file not available on win32"
msgstr "" msgstr ""

View File

@ -184,7 +184,7 @@ size_t common_hal_camera_take_picture(camera_obj_t *self, uint8_t *buffer, size_
mp_raise_ValueError(translate("Size not supported")); mp_raise_ValueError(translate("Size not supported"));
} }
if (!camera_check_buffer_length(width, height, format, len)) { if (!camera_check_buffer_length(width, height, format, len)) {
mp_raise_ValueError(translate("Buffer is too small")); mp_raise_ValueError(translate("Buffer too small"));
} }
if (!camera_check_format(format)) { if (!camera_check_format(format)) {
mp_raise_ValueError(translate("Format not supported")); mp_raise_ValueError(translate("Format not supported"));

View File

@ -506,7 +506,7 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po
displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); displayio_display_core_fill_area(&self->core, &area, mask, result_buffer);
return result; return result;
} else { } else {
mp_raise_ValueError(translate("Buffer is too small")); mp_raise_ValueError(translate("Buffer too small"));
} }
} }
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row); MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row);

View File

@ -351,7 +351,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_pixel_shader_obj, displayio_til
STATIC mp_obj_t displayio_tilegrid_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) { STATIC mp_obj_t displayio_tilegrid_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) {
displayio_tilegrid_t *self = native_tilegrid(self_in); displayio_tilegrid_t *self = native_tilegrid(self_in);
if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) {
mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter")); mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);
} }
common_hal_displayio_tilegrid_set_pixel_shader(self, pixel_shader); common_hal_displayio_tilegrid_set_pixel_shader(self, pixel_shader);

View File

@ -317,7 +317,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, con
displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); displayio_display_core_fill_area(&self->core, &area, mask, result_buffer);
return result; return result;
} else { } else {
mp_raise_ValueError(translate("Buffer is too small")); mp_raise_ValueError(translate("Buffer too small"));
} }
} }
MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, framebufferio_framebufferdisplay_obj_fill_row); MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, framebufferio_framebufferdisplay_obj_fill_row);

View File

@ -92,7 +92,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
// negative offsets are relative to the end of the buffer // negative offsets are relative to the end of the buffer
offset = (mp_int_t)bufinfo.len + offset; offset = (mp_int_t)bufinfo.len + offset;
if (offset < 0) { if (offset < 0) {
mp_raise_RuntimeError(translate("buffer too small")); mp_raise_RuntimeError(translate("Buffer too small"));
} }
} }
byte *p = (byte *)bufinfo.buf; byte *p = (byte *)bufinfo.buf;
@ -151,7 +151,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_m
// negative offsets are relative to the end of the buffer // negative offsets are relative to the end of the buffer
offset = bufinfo.len + offset; offset = bufinfo.len + offset;
if (offset < 0) { if (offset < 0) {
mp_raise_RuntimeError(translate("buffer too small")); mp_raise_RuntimeError(translate("Buffer too small"));
} }
} }
p += offset; p += offset;

View File

@ -226,7 +226,7 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_pixel_shader(mp_obj_t wrapper_shap
vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape)); vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape));
if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) {
mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter")); mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);
} }
common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader); common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader);

View File

@ -126,7 +126,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size
const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in); const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in);
if (p + total_sz > end_p) { if (p + total_sz > end_p) {
mp_raise_RuntimeError(translate("buffer too small")); mp_raise_RuntimeError(translate("Buffer too small"));
} }
size_t i = 0; size_t i = 0;

View File

@ -154,7 +154,7 @@ void print_safe_mode_message(safe_mode_t reason) {
switch (reason) { switch (reason) {
case SAFE_MODE_BROWNOUT: case SAFE_MODE_BROWNOUT:
message = translate("The power dipped. Make sure you are providing enough power."); message = translate("Power dipped. Make sure you are providing enough power.");
break; break;
case SAFE_MODE_USER: case SAFE_MODE_USER:
#if defined(BOARD_USER_SAFE_MODE_ACTION) #if defined(BOARD_USER_SAFE_MODE_ACTION)
@ -228,7 +228,7 @@ void print_safe_mode_message(safe_mode_t reason) {
break; break;
} }
serial_write_compressed(message); serial_write_compressed(message);
serial_write_compressed(translate("\nPlease file an issue with your program at https://github.com/adafruit/circuitpython/issues.")); serial_write_compressed(translate("\nPlease file an issue with your program at github.com/adafruit/circuitpython/issues."));
} }
// Always tell user how to get out of safe mode. // Always tell user how to get out of safe mode.