Skip to content

Commit 7e7751e

Browse files
committed
Don't show SystemExit or KeyboardInterrupt on the display.
They are exceptions that the user is expecting so don't need to be scrolled across the display.
1 parent 3bf9d04 commit 7e7751e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/microbit/mprun.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ void do_strn(const char *src, size_t len) {
5555
} else {
5656
// uncaught exception
5757
mp_hal_set_interrupt_char(-1); // disable interrupt
58+
59+
// print exception to stdout
5860
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
59-
microbit_display_exception(nlr.ret_val);
61+
62+
// print exception to the display, but not if it's SystemExit or KeyboardInterrupt
63+
mp_obj_type_t *exc_type = mp_obj_get_type((mp_obj_t)nlr.ret_val);
64+
if (!mp_obj_is_subclass_fast(exc_type, &mp_type_SystemExit)
65+
&& !mp_obj_is_subclass_fast(exc_type, &mp_type_KeyboardInterrupt)) {
66+
microbit_display_exception(nlr.ret_val);
67+
}
6068
}
6169
}
6270

0 commit comments

Comments
 (0)