1use alloc::vec::Vec;
4
5use crate::{
6 component::ComponentId,
7 entity::{Entity, EntityDoesNotExistError},
8 schedule::InternedScheduleLabel,
9};
10
11#[derive(thiserror::Error, Debug)]
15#[error("The schedule with the label {0:?} was not found.")]
16pub struct TryRunScheduleError(pub InternedScheduleLabel);
17
18#[derive(thiserror::Error, Debug, Clone)]
24#[error("Could not insert bundles of type {bundle_type} into the entities with the following IDs because they do not exist: {entities:?}")]
25pub struct TryInsertBatchError {
26 pub bundle_type: &'static str,
28 pub entities: Vec<Entity>,
30}
31
32#[derive(thiserror::Error, Debug, Clone, Copy)]
34#[error("Could not despawn entity: {0}")]
35pub struct EntityDespawnError(#[from] pub EntityMutableFetchError);
36
37#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
39pub enum EntityComponentError {
40 #[error("The component with ID {0:?} does not exist on the entity.")]
42 MissingComponent(ComponentId),
43 #[error("The component with ID {0:?} was requested mutably more than once.")]
45 AliasedMutability(ComponentId),
46}
47
48#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
50pub enum EntityMutableFetchError {
51 #[error(transparent)]
53 EntityDoesNotExist(#[from] EntityDoesNotExistError),
54 #[error("The entity with ID {0} was requested mutably more than once")]
56 AliasedMutability(Entity),
57}
58
59#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
61pub enum ResourceFetchError {
62 #[error("The resource has never been initialized or registered with the world. Did you forget to add it using `app.insert_resource` / `app.init_resource`?")]
64 NotRegistered,
65 #[error("The resource with ID {0:?} does not currently exist in the world.")]
67 DoesNotExist(ComponentId),
68 #[error("Cannot get access to the resource with ID {0:?} in the world as it conflicts with an on going operation.")]
70 NoResourceAccess(ComponentId),
71}