bevy_ecs/world/
error.rs

1//! Contains error types returned by bevy's schedule.
2
3use derive_more::derive::{Display, Error};
4
5use crate::{component::ComponentId, entity::Entity, schedule::InternedScheduleLabel};
6
7/// The error type returned by [`World::try_run_schedule`] if the provided schedule does not exist.
8///
9/// [`World::try_run_schedule`]: crate::world::World::try_run_schedule
10#[derive(Error, Display, Debug)]
11#[display("The schedule with the label {_0:?} was not found.")]
12#[error(ignore)]
13pub struct TryRunScheduleError(pub InternedScheduleLabel);
14
15/// An error that occurs when dynamically retrieving components from an entity.
16#[derive(Error, Display, Debug, Clone, Copy, PartialEq, Eq)]
17pub enum EntityComponentError {
18    /// The component with the given [`ComponentId`] does not exist on the entity.
19    #[display("The component with ID {_0:?} does not exist on the entity.")]
20    #[error(ignore)]
21    MissingComponent(ComponentId),
22    /// The component with the given [`ComponentId`] was requested mutably more than once.
23    #[display("The component with ID {_0:?} was requested mutably more than once.")]
24    #[error(ignore)]
25    AliasedMutability(ComponentId),
26}
27
28/// An error that occurs when fetching entities mutably from a world.
29#[derive(Error, Display, Debug, Clone, Copy, PartialEq, Eq)]
30pub enum EntityFetchError {
31    /// The entity with the given ID does not exist.
32    #[display("The entity with ID {_0:?} does not exist.")]
33    #[error(ignore)]
34    NoSuchEntity(Entity),
35    /// The entity with the given ID was requested mutably more than once.
36    #[display("The entity with ID {_0:?} was requested mutably more than once.")]
37    #[error(ignore)]
38    AliasedMutability(Entity),
39}