mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Throw real error messages on all failed attempts to get StateTransition
schedule (#15284)
# Objective Make it clear to the user why their program is failing rather than having an unhelpful `called Option::unwrap() on a None value` message. ## Solution Change the `unwrap()` calls to `expect()` calls, mirroring previously implemented error messages. ## Testing I have not tested these changes, but they are fairly trivial so I do not necessarily feel they need it.
This commit is contained in:
parent
69541462c5
commit
fbb9b36441
1 changed files with 7 additions and 3 deletions
|
@ -117,7 +117,7 @@ impl AppExtStates for SubApp {
|
|||
.init_resource::<NextState<S>>()
|
||||
.add_event::<StateTransitionEvent<S>>();
|
||||
let schedule = self.get_schedule_mut(StateTransition).expect(
|
||||
"The `StateTransition` schedule is missing. Did you forget to add StatesPlugin or DefaultPlugins before calling init_state?"
|
||||
"The `StateTransition` schedule is missing. Did you forget to add StatesPlugin or DefaultPlugins before calling insert_state?"
|
||||
);
|
||||
S::register_state(schedule);
|
||||
self.world_mut().send_event(StateTransitionEvent {
|
||||
|
@ -146,7 +146,9 @@ impl AppExtStates for SubApp {
|
|||
.contains_resource::<Events<StateTransitionEvent<S>>>()
|
||||
{
|
||||
self.add_event::<StateTransitionEvent<S>>();
|
||||
let schedule = self.get_schedule_mut(StateTransition).unwrap();
|
||||
let schedule = self.get_schedule_mut(StateTransition).expect(
|
||||
"The `StateTransition` schedule is missing. Did you forget to add StatesPlugin or DefaultPlugins before calling add_computed_state?"
|
||||
);
|
||||
S::register_computed_state_systems(schedule);
|
||||
let state = self
|
||||
.world()
|
||||
|
@ -172,7 +174,9 @@ impl AppExtStates for SubApp {
|
|||
{
|
||||
self.init_resource::<NextState<S>>();
|
||||
self.add_event::<StateTransitionEvent<S>>();
|
||||
let schedule = self.get_schedule_mut(StateTransition).unwrap();
|
||||
let schedule = self.get_schedule_mut(StateTransition).expect(
|
||||
"The `StateTransition` schedule is missing. Did you forget to add StatesPlugin or DefaultPlugins before calling add_sub_state?"
|
||||
);
|
||||
S::register_sub_state_systems(schedule);
|
||||
let state = self
|
||||
.world()
|
||||
|
|
Loading…
Reference in a new issue