all: Convert exceptions to use mp_raise_XXX helpers in remaining places.

This commit is contained in:
Damien George
2020-03-18 17:26:19 +11:00
parent 8f0778b209
commit ad9a0ec8ab
6 changed files with 12 additions and 12 deletions

View File

@@ -227,7 +227,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
return image_from_parsed_str(str, len);
}
} else {
mp_raise_msg(&mp_type_TypeError, "Image(s) takes a string.");
mp_raise_TypeError("Image(s) takes a string.");
}
}
@@ -258,7 +258,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
}
default: {
mp_raise_msg(&mp_type_TypeError, "Image() takes 0 to 3 arguments");
mp_raise_TypeError("Image() takes 0 to 3 arguments");
}
}
}
@@ -363,7 +363,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(microbit_image_get_pixel_obj, microbit_image_get_pixel
/* Raise an exception if not mutable */
static void check_mutability(microbit_image_obj_t *self) {
if (self->base.five) {
mp_raise_msg(&mp_type_TypeError, "image cannot be modified (try copying first)");
mp_raise_TypeError("image cannot be modified (try copying first)");
}
}
@@ -406,10 +406,10 @@ mp_obj_t microbit_image_blit(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_t src = args[1];
if (mp_obj_get_type(src) != &microbit_image_type) {
mp_raise_msg(&mp_type_TypeError, "expecting an image");
mp_raise_TypeError("expecting an image");
}
if (n_args == 7) {
mp_raise_msg(&mp_type_TypeError, "must specify both offsets");
mp_raise_TypeError("must specify both offsets");
}
mp_int_t x = mp_obj_get_int(args[2]);
mp_int_t y = mp_obj_get_int(args[3]);