diff --git a/manimlib/config.py b/manimlib/config.py index e2538777..17e203ab 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -492,4 +492,5 @@ def get_configuration(args: Namespace) -> dict: "leave_progress_bars": args.leave_progress_bars, "show_animation_progress": args.show_animation_progress, "embed_exception_mode": custom_config["embed_exception_mode"], + "embed_error_sound": custom_config["embed_error_sound"], } diff --git a/manimlib/default_config.yml b/manimlib/default_config.yml index 50023006..bfee5293 100644 --- a/manimlib/default_config.yml +++ b/manimlib/default_config.yml @@ -43,3 +43,4 @@ camera_resolutions: default_resolution: "high" fps: 30 embed_exception_mode: "Verbose" +embed_error_sound: False diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index 398fd164..66d1d529 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -74,7 +74,8 @@ class Scene(object): preview: bool = True, presenter_mode: bool = False, show_animation_progress: bool = False, - embed_exception_mode = "", + embed_exception_mode: str = "", + embed_error_sound: bool = False, ): self.skip_animations = skip_animations self.always_update_mobjects = always_update_mobjects @@ -85,6 +86,7 @@ class Scene(object): self.presenter_mode = presenter_mode self.show_animation_progress = show_animation_progress self.embed_exception_mode = embed_exception_mode + self.embed_error_sound = embed_error_sound self.camera_config = {**self.default_camera_config, **camera_config} self.window_config = {**self.default_window_config, **window_config} @@ -251,6 +253,16 @@ class Scene(object): shell.events.register("post_run_cell", post_cell_func) + if self.embed_error_sound: + # Play sound after any Exceptions + def custom_exc(shell, etype, evalue, tb, tb_offset=None): + # still show the error don't just swallow it + shell.showtraceback((etype, evalue, tb), tb_offset=tb_offset) + os.system("printf '\a'") + + shell.set_custom_exc((Exception,), custom_exc) + + # Set desired exception mode shell.magic(f"xmode {self.embed_exception_mode}") # Launch shell