Skip to content

Commit

Permalink
Improve the panic message for schedule build errors (#7860)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
JoJoJet committed Mar 1, 2023
1 parent 002c9d8 commit 4fd12d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 4fd12d0

Please sign in to comment.