Skip to content

Commit

Permalink
Improve the panic message for schedule build errors (bevyengine#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 authored and Shfty committed Mar 19, 2023
1 parent e712fa5 commit 54edab7
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 54edab7

Please sign in to comment.