From 54edab764039ca01b9c48b1ebad1bcb8e89d2750 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Wed, 1 Mar 2023 20:18:15 +0000 Subject: [PATCH] Improve the panic message for schedule build errors (#7860) # Objective The `ScheduleBuildError` type has a `Display` implementation which beautifully formats the error. However, schedule build errors are currently reported using `unwrap()`, which uses the `Debug` implementation and makes the error message look unfished. ## Solution Use `unwrap_or_else` so we can customize the formatting of the error message. --- crates/bevy_ecs/src/schedule/schedule.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 6ce97433c58c9f..df4b26c6cb6ad3 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -245,7 +245,7 @@ impl Schedule { /// Runs all systems in this schedule on the `world`, using its current execution strategy. pub fn run(&mut self, world: &mut World) { world.check_change_ticks(); - self.initialize(world).unwrap(); + self.initialize(world).unwrap_or_else(|e| panic!("{e}")); self.executor.run(&mut self.executable, world); }