Function install_panic_handler

Source
pub fn install_panic_handler()
Expand description

Installs a panic handler that cleans up the terminal before panicking. Without this, the panic message would not be displayed properly because we’re in a different terminal mode and in the alternate screen.

Examples found in repository?
examples/boundschecker.rs (line 16)
14fn main() -> io::Result<()> {
15    terminal_setup()?;
16    install_panic_handler();
17
18    let mut game = Game::new(stdout());
19    game.install_recommended_components();
20    game.add_component(Box::new(BoundsCheckerComponent::new()));
21    game.run()?;
22
23    terminal_cleanup()?;
24
25    Ok(())
26}
More examples
Hide additional examples
examples/falling-sand/main.rs (line 14)
12fn main() -> std::io::Result<()> {
13    terminal_setup()?;
14    install_panic_handler();
15
16    let mut game = Game::new(stdout());
17    game.install_recommended_components();
18    game.add_component(Box::new(FallingSimulationComponent::new()));
19    game.run()?;
20
21    terminal_cleanup()?;
22
23    Ok(())
24}
examples/exponentialgrowingboundschecker.rs (line 18)
16fn main() -> io::Result<()> {
17    terminal_setup()?;
18    install_panic_handler();
19
20    let mut game = Game::new(stdout());
21    game.install_recommended_components();
22    game.add_component(Box::new(ExponentialBoundsCheckerComponent::new()));
23    game.run()?;
24
25    terminal_cleanup()?;
26
27    Ok(())
28}
examples/fpschecker.rs (line 13)
11fn main() -> io::Result<()> {
12    terminal_setup()?;
13    install_panic_handler();
14
15    let mut game = Game::new(stdout());
16    game.install_recommended_components();
17    // game.add_component(Box::new(FpsCheckerComponent::new()));
18    game.add_component(Box::new(FpsCheckerFrameCountComponent::new()));
19    game.run()?;
20
21    terminal_cleanup()?;
22
23    Ok(())
24}
examples/ecs/main.rs (line 73)
71fn main() -> io::Result<()> {
72    teng::terminal_setup()?;
73    teng::install_panic_handler();
74
75    let mut game = Game::new(stdout());
76    game.install_recommended_components();
77    game.add_component(Box::new(EcsComponent::default()));
78    game.add_component(Box::new(DrawSystem));
79    game.add_component(Box::new(PhysicsSystem));
80    game.run()?;
81
82    teng::terminal_cleanup()?;
83    Ok(())
84}
examples/simple.rs (line 27)
25fn main() -> io::Result<()> {
26    terminal_setup()?;
27    install_panic_handler();
28
29    let mut game = Game::new_with_custom_buf_writer();
30    // If you don't install the recommended components, you will need to have your own
31    // component that exits the process, since Ctrl-C does not work in raw mode.
32    game.install_recommended_components();
33    game.add_component(Box::new(MyComponent));
34    game.run()?;
35
36    terminal_cleanup()?;
37
38    Ok(())
39}