Remove thiserror from bevy_ecs (#15774)
# Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_ecs`
This commit is contained in:
parent
4c76ea7a5a
commit
0a61f04d9b
@ -32,7 +32,13 @@ concurrent-queue = "2.4.0"
|
|||||||
disqualified = "1.0"
|
disqualified = "1.0"
|
||||||
fixedbitset = "0.5"
|
fixedbitset = "0.5"
|
||||||
serde = { version = "1", optional = true, default-features = false }
|
serde = { version = "1", optional = true, default-features = false }
|
||||||
thiserror = "1.0"
|
derive_more = { version = "1", default-features = false, features = [
|
||||||
|
"error",
|
||||||
|
"from",
|
||||||
|
"display",
|
||||||
|
"into",
|
||||||
|
"as_ref",
|
||||||
|
] }
|
||||||
nonmax = "0.5"
|
nonmax = "0.5"
|
||||||
arrayvec = { version = "0.7.4", optional = true }
|
arrayvec = { version = "0.7.4", optional = true }
|
||||||
smallvec = "1"
|
smallvec = "1"
|
||||||
|
|||||||
@ -27,7 +27,7 @@ use core::{
|
|||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
mem::needs_drop,
|
mem::needs_drop,
|
||||||
};
|
};
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
/// A data type that can be used to store data for an [entity].
|
/// A data type that can be used to store data for an [entity].
|
||||||
///
|
///
|
||||||
@ -1623,14 +1623,18 @@ impl<T: Component> FromWorld for InitComponentId<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An error returned when the registration of a required component fails.
|
/// An error returned when the registration of a required component fails.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum RequiredComponentsError {
|
pub enum RequiredComponentsError {
|
||||||
/// The component is already a directly required component for the requiree.
|
/// The component is already a directly required component for the requiree.
|
||||||
#[error("Component {0:?} already directly requires component {1:?}")]
|
#[display("Component {0:?} already directly requires component {_1:?}")]
|
||||||
|
#[error(ignore)]
|
||||||
DuplicateRegistration(ComponentId, ComponentId),
|
DuplicateRegistration(ComponentId, ComponentId),
|
||||||
/// An archetype with the component that requires other components already exists
|
/// An archetype with the component that requires other components already exists
|
||||||
#[error("An archetype with the component {0:?} that requires other components already exists")]
|
#[display(
|
||||||
|
"An archetype with the component {_0:?} that requires other components already exists"
|
||||||
|
)]
|
||||||
|
#[error(ignore)]
|
||||||
ArchetypeExists(ComponentId),
|
ArchetypeExists(ComponentId),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use crate::component::ComponentId;
|
|||||||
use crate::storage::SparseSetIndex;
|
use crate::storage::SparseSetIndex;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use core::{fmt, fmt::Debug, marker::PhantomData};
|
use core::{fmt, fmt::Debug, marker::PhantomData};
|
||||||
|
use derive_more::derive::From;
|
||||||
use fixedbitset::FixedBitSet;
|
use fixedbitset::FixedBitSet;
|
||||||
|
|
||||||
/// A wrapper struct to make Debug representations of [`FixedBitSet`] easier
|
/// A wrapper struct to make Debug representations of [`FixedBitSet`] easier
|
||||||
@ -856,7 +857,7 @@ impl<T: SparseSetIndex> From<FilteredAccess<T>> for FilteredAccessSet<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Records how two accesses conflict with each other
|
/// Records how two accesses conflict with each other
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, From)]
|
||||||
pub enum AccessConflicts {
|
pub enum AccessConflicts {
|
||||||
/// Conflict is for all indices
|
/// Conflict is for all indices
|
||||||
All,
|
All,
|
||||||
@ -908,12 +909,6 @@ impl AccessConflicts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FixedBitSet> for AccessConflicts {
|
|
||||||
fn from(value: FixedBitSet) -> Self {
|
|
||||||
Self::Individual(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: SparseSetIndex> From<Vec<T>> for AccessConflicts {
|
impl<T: SparseSetIndex> From<Vec<T>> for AccessConflicts {
|
||||||
fn from(value: Vec<T>) -> Self {
|
fn from(value: Vec<T>) -> Self {
|
||||||
Self::Individual(value.iter().map(T::sparse_set_index).collect())
|
Self::Individual(value.iter().map(T::sparse_set_index).collect())
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
use crate::{entity::Entity, world::unsafe_world_cell::UnsafeWorldCell};
|
use crate::{entity::Entity, world::unsafe_world_cell::UnsafeWorldCell};
|
||||||
|
|
||||||
@ -90,13 +90,15 @@ impl<'w> Eq for QueryEntityError<'w> {}
|
|||||||
|
|
||||||
/// An error that occurs when evaluating a [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState) as a single expected result via
|
/// An error that occurs when evaluating a [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState) as a single expected result via
|
||||||
/// [`get_single`](crate::system::Query::get_single) or [`get_single_mut`](crate::system::Query::get_single_mut).
|
/// [`get_single`](crate::system::Query::get_single) or [`get_single_mut`](crate::system::Query::get_single_mut).
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error, Display)]
|
||||||
pub enum QuerySingleError {
|
pub enum QuerySingleError {
|
||||||
/// No entity fits the query.
|
/// No entity fits the query.
|
||||||
#[error("No entities fit the query {0}")]
|
#[display("No entities fit the query {_0}")]
|
||||||
|
#[error(ignore)]
|
||||||
NoEntities(&'static str),
|
NoEntities(&'static str),
|
||||||
/// Multiple entities fit the query.
|
/// Multiple entities fit the query.
|
||||||
#[error("Multiple entities fit the query {0}")]
|
#[display("Multiple entities fit the query {_0}")]
|
||||||
|
#[error(ignore)]
|
||||||
MultipleEntities(&'static str),
|
MultipleEntities(&'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,8 @@ use crate::{
|
|||||||
world::{unsafe_world_cell::UnsafeWorldCell, World},
|
world::{unsafe_world_cell::UnsafeWorldCell, World},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use derive_more::derive::Into;
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
iter,
|
iter,
|
||||||
@ -21,15 +23,9 @@ use core::{
|
|||||||
|
|
||||||
/// Wrapper around [`Entity`] for [`RemovedComponents`].
|
/// Wrapper around [`Entity`] for [`RemovedComponents`].
|
||||||
/// Internally, `RemovedComponents` uses these as an `Events<RemovedComponentEntity>`.
|
/// Internally, `RemovedComponents` uses these as an `Events<RemovedComponentEntity>`.
|
||||||
#[derive(Event, Debug, Clone)]
|
#[derive(Event, Debug, Clone, Into)]
|
||||||
pub struct RemovedComponentEntity(Entity);
|
pub struct RemovedComponentEntity(Entity);
|
||||||
|
|
||||||
impl From<RemovedComponentEntity> for Entity {
|
|
||||||
fn from(value: RemovedComponentEntity) -> Self {
|
|
||||||
value.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Wrapper around a [`EventCursor<RemovedComponentEntity>`] so that we
|
/// Wrapper around a [`EventCursor<RemovedComponentEntity>`] so that we
|
||||||
/// can differentiate events between components.
|
/// can differentiate events between components.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@ -8,10 +8,10 @@ use bevy_utils::{
|
|||||||
tracing::{error, info, warn},
|
tracing::{error, info, warn},
|
||||||
HashMap, HashSet,
|
HashMap, HashSet,
|
||||||
};
|
};
|
||||||
|
use derive_more::derive::{Display, Error};
|
||||||
use disqualified::ShortName;
|
use disqualified::ShortName;
|
||||||
use fixedbitset::FixedBitSet;
|
use fixedbitset::FixedBitSet;
|
||||||
use petgraph::{algo::TarjanScc, prelude::*};
|
use petgraph::{algo::TarjanScc, prelude::*};
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_ecs,
|
self as bevy_ecs,
|
||||||
@ -1934,42 +1934,43 @@ impl ScheduleGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Category of errors encountered during schedule construction.
|
/// Category of errors encountered during schedule construction.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
|
#[error(ignore)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ScheduleBuildError {
|
pub enum ScheduleBuildError {
|
||||||
/// A system set contains itself.
|
/// A system set contains itself.
|
||||||
#[error("System set `{0}` contains itself.")]
|
#[display("System set `{_0}` contains itself.")]
|
||||||
HierarchyLoop(String),
|
HierarchyLoop(String),
|
||||||
/// The hierarchy of system sets contains a cycle.
|
/// The hierarchy of system sets contains a cycle.
|
||||||
#[error("System set hierarchy contains cycle(s).\n{0}")]
|
#[display("System set hierarchy contains cycle(s).\n{_0}")]
|
||||||
HierarchyCycle(String),
|
HierarchyCycle(String),
|
||||||
/// The hierarchy of system sets contains redundant edges.
|
/// The hierarchy of system sets contains redundant edges.
|
||||||
///
|
///
|
||||||
/// This error is disabled by default, but can be opted-in using [`ScheduleBuildSettings`].
|
/// This error is disabled by default, but can be opted-in using [`ScheduleBuildSettings`].
|
||||||
#[error("System set hierarchy contains redundant edges.\n{0}")]
|
#[display("System set hierarchy contains redundant edges.\n{_0}")]
|
||||||
HierarchyRedundancy(String),
|
HierarchyRedundancy(String),
|
||||||
/// A system (set) has been told to run before itself.
|
/// A system (set) has been told to run before itself.
|
||||||
#[error("System set `{0}` depends on itself.")]
|
#[display("System set `{_0}` depends on itself.")]
|
||||||
DependencyLoop(String),
|
DependencyLoop(String),
|
||||||
/// The dependency graph contains a cycle.
|
/// The dependency graph contains a cycle.
|
||||||
#[error("System dependencies contain cycle(s).\n{0}")]
|
#[display("System dependencies contain cycle(s).\n{_0}")]
|
||||||
DependencyCycle(String),
|
DependencyCycle(String),
|
||||||
/// Tried to order a system (set) relative to a system set it belongs to.
|
/// Tried to order a system (set) relative to a system set it belongs to.
|
||||||
#[error("`{0}` and `{1}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to.")]
|
#[display("`{0}` and `{_1}` have both `in_set` and `before`-`after` relationships (these might be transitive). This combination is unsolvable as a system cannot run before or after a set it belongs to.")]
|
||||||
CrossDependency(String, String),
|
CrossDependency(String, String),
|
||||||
/// Tried to order system sets that share systems.
|
/// Tried to order system sets that share systems.
|
||||||
#[error("`{0}` and `{1}` have a `before`-`after` relationship (which may be transitive) but share systems.")]
|
#[display("`{0}` and `{_1}` have a `before`-`after` relationship (which may be transitive) but share systems.")]
|
||||||
SetsHaveOrderButIntersect(String, String),
|
SetsHaveOrderButIntersect(String, String),
|
||||||
/// Tried to order a system (set) relative to all instances of some system function.
|
/// Tried to order a system (set) relative to all instances of some system function.
|
||||||
#[error("Tried to order against `{0}` in a schedule that has more than one `{0}` instance. `{0}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction.")]
|
#[display("Tried to order against `{0}` in a schedule that has more than one `{0}` instance. `{_0}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction.")]
|
||||||
SystemTypeSetAmbiguity(String),
|
SystemTypeSetAmbiguity(String),
|
||||||
/// Systems with conflicting access have indeterminate run order.
|
/// Systems with conflicting access have indeterminate run order.
|
||||||
///
|
///
|
||||||
/// This error is disabled by default, but can be opted-in using [`ScheduleBuildSettings`].
|
/// This error is disabled by default, but can be opted-in using [`ScheduleBuildSettings`].
|
||||||
#[error("Systems with conflicting access have indeterminate run order.\n{0}")]
|
#[display("Systems with conflicting access have indeterminate run order.\n{_0}")]
|
||||||
Ambiguity(String),
|
Ambiguity(String),
|
||||||
/// Tried to run a schedule before all of its systems have been initialized.
|
/// Tried to run a schedule before all of its systems have been initialized.
|
||||||
#[error("Systems in schedule have not been initialized.")]
|
#[display("Systems in schedule have not been initialized.")]
|
||||||
Uninitialized,
|
Uninitialized,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2040,8 +2041,8 @@ impl ScheduleBuildSettings {
|
|||||||
|
|
||||||
/// Error to denote that [`Schedule::initialize`] or [`Schedule::run`] has not yet been called for
|
/// Error to denote that [`Schedule::initialize`] or [`Schedule::run`] has not yet been called for
|
||||||
/// this schedule.
|
/// this schedule.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
#[error("executable schedule has not been built")]
|
#[display("executable schedule has not been built")]
|
||||||
pub struct ScheduleNotInitialized;
|
pub struct ScheduleNotInitialized;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@ -7,10 +7,13 @@ use crate::{
|
|||||||
system::{IntoSystem, ResMut, Resource},
|
system::{IntoSystem, ResMut, Resource},
|
||||||
};
|
};
|
||||||
use bevy_utils::{
|
use bevy_utils::{
|
||||||
tracing::{error, info, warn},
|
tracing::{info, warn},
|
||||||
TypeIdMap,
|
TypeIdMap,
|
||||||
};
|
};
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "bevy_debug_stepping"))]
|
||||||
|
use bevy_utils::tracing::error;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use bevy_utils::tracing::debug;
|
use bevy_utils::tracing::debug;
|
||||||
@ -87,8 +90,8 @@ enum Update {
|
|||||||
ClearBehavior(InternedScheduleLabel, SystemIdentifier),
|
ClearBehavior(InternedScheduleLabel, SystemIdentifier),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
#[error("not available until all configured schedules have been run; try again next frame")]
|
#[display("not available until all configured schedules have been run; try again next frame")]
|
||||||
pub struct NotReady;
|
pub struct NotReady;
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use bevy_utils::tracing::warn;
|
use bevy_utils::tracing::warn;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
archetype::ArchetypeComponentId,
|
archetype::ArchetypeComponentId,
|
||||||
@ -357,12 +357,13 @@ impl RunSystemOnce for &mut World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Running system failed.
|
/// Running system failed.
|
||||||
#[derive(Error)]
|
#[derive(Error, Display)]
|
||||||
pub enum RunSystemError {
|
pub enum RunSystemError {
|
||||||
/// System could not be run due to parameters that failed validation.
|
/// System could not be run due to parameters that failed validation.
|
||||||
///
|
///
|
||||||
/// This can occur because the data required by the system was not present in the world.
|
/// This can occur because the data required by the system was not present in the world.
|
||||||
#[error("The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation.")]
|
#[display("The data required by the system {_0:?} was not found in the world and the system did not run due to failed parameter validation.")]
|
||||||
|
#[error(ignore)]
|
||||||
InvalidParams(Cow<'static, str>),
|
InvalidParams(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use alloc::borrow::Cow;
|
use alloc::borrow::Cow;
|
||||||
use core::ops::Deref;
|
use core::ops::Deref;
|
||||||
|
use derive_more::derive::{AsRef, Display, Into};
|
||||||
|
|
||||||
/// [`SystemParam`] that returns the name of the system which it is used in.
|
/// [`SystemParam`] that returns the name of the system which it is used in.
|
||||||
///
|
///
|
||||||
@ -33,7 +34,8 @@ use core::ops::Deref;
|
|||||||
/// logger.log("Hello");
|
/// logger.log("Hello");
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Into, Display, AsRef)]
|
||||||
|
#[as_ref(str)]
|
||||||
pub struct SystemName<'s>(&'s str);
|
pub struct SystemName<'s>(&'s str);
|
||||||
|
|
||||||
impl<'s> SystemName<'s> {
|
impl<'s> SystemName<'s> {
|
||||||
@ -50,25 +52,6 @@ impl<'s> Deref for SystemName<'s> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> AsRef<str> for SystemName<'s> {
|
|
||||||
fn as_ref(&self) -> &str {
|
|
||||||
self.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'s> From<SystemName<'s>> for &'s str {
|
|
||||||
fn from(name: SystemName<'s>) -> &'s str {
|
|
||||||
name.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'s> core::fmt::Display for SystemName<'s> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
|
||||||
core::fmt::Display::fmt(&self.name(), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SAFETY: no component value access
|
// SAFETY: no component value access
|
||||||
unsafe impl SystemParam for SystemName<'_> {
|
unsafe impl SystemParam for SystemName<'_> {
|
||||||
type State = Cow<'static, str>;
|
type State = Cow<'static, str>;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use bevy_ecs_macros::{Component, Resource};
|
|||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
/// A small wrapper for [`BoxedSystem`] that also keeps track whether or not the system has been initialized.
|
/// A small wrapper for [`BoxedSystem`] that also keeps track whether or not the system has been initialized.
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
@ -587,28 +587,28 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An operation with stored systems failed.
|
/// An operation with stored systems failed.
|
||||||
#[derive(Error)]
|
#[derive(Error, Display)]
|
||||||
pub enum RegisteredSystemError<I: SystemInput = (), O = ()> {
|
pub enum RegisteredSystemError<I: SystemInput = (), O = ()> {
|
||||||
/// A system was run by id, but no system with that id was found.
|
/// A system was run by id, but no system with that id was found.
|
||||||
///
|
///
|
||||||
/// Did you forget to register it?
|
/// Did you forget to register it?
|
||||||
#[error("System {0:?} was not registered")]
|
#[display("System {_0:?} was not registered")]
|
||||||
SystemIdNotRegistered(SystemId<I, O>),
|
SystemIdNotRegistered(SystemId<I, O>),
|
||||||
/// A cached system was removed by value, but no system with its type was found.
|
/// A cached system was removed by value, but no system with its type was found.
|
||||||
///
|
///
|
||||||
/// Did you forget to register it?
|
/// Did you forget to register it?
|
||||||
#[error("Cached system was not found")]
|
#[display("Cached system was not found")]
|
||||||
SystemNotCached,
|
SystemNotCached,
|
||||||
/// A system tried to run itself recursively.
|
/// A system tried to run itself recursively.
|
||||||
#[error("System {0:?} tried to run itself recursively")]
|
#[display("System {_0:?} tried to run itself recursively")]
|
||||||
Recursive(SystemId<I, O>),
|
Recursive(SystemId<I, O>),
|
||||||
/// A system tried to remove itself.
|
/// A system tried to remove itself.
|
||||||
#[error("System {0:?} tried to remove itself")]
|
#[display("System {_0:?} tried to remove itself")]
|
||||||
SelfRemove(SystemId<I, O>),
|
SelfRemove(SystemId<I, O>),
|
||||||
/// System could not be run due to parameters that failed validation.
|
/// System could not be run due to parameters that failed validation.
|
||||||
///
|
///
|
||||||
/// This can occur because the data required by the system was not present in the world.
|
/// This can occur because the data required by the system was not present in the world.
|
||||||
#[error("The data required by the system {0:?} was not found in the world and the system did not run due to failed parameter validation.")]
|
#[display("The data required by the system {_0:?} was not found in the world and the system did not run due to failed parameter validation.")]
|
||||||
InvalidParams(SystemId<I, O>),
|
InvalidParams(SystemId<I, O>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use crate::{
|
|||||||
use bevy_ptr::{OwningPtr, Ptr};
|
use bevy_ptr::{OwningPtr, Ptr};
|
||||||
use bevy_utils::{HashMap, HashSet};
|
use bevy_utils::{HashMap, HashSet};
|
||||||
use core::{any::TypeId, marker::PhantomData, mem::MaybeUninit};
|
use core::{any::TypeId, marker::PhantomData, mem::MaybeUninit};
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
use super::{unsafe_world_cell::UnsafeEntityCell, Ref, ON_REMOVE, ON_REPLACE};
|
use super::{unsafe_world_cell::UnsafeEntityCell, Ref, ON_REMOVE, ON_REPLACE};
|
||||||
|
|
||||||
@ -2774,12 +2774,16 @@ impl<'a> From<&'a mut EntityWorldMut<'_>> for FilteredEntityMut<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
pub enum TryFromFilteredError {
|
pub enum TryFromFilteredError {
|
||||||
#[error("Conversion failed, filtered entity ref does not have read access to all components")]
|
#[display(
|
||||||
|
"Conversion failed, filtered entity ref does not have read access to all components"
|
||||||
|
)]
|
||||||
MissingReadAllAccess,
|
MissingReadAllAccess,
|
||||||
|
|
||||||
#[error("Conversion failed, filtered entity ref does not have write access to all components")]
|
#[display(
|
||||||
|
"Conversion failed, filtered entity ref does not have write access to all components"
|
||||||
|
)]
|
||||||
MissingWriteAllAccess,
|
MissingWriteAllAccess,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,34 +1,39 @@
|
|||||||
//! Contains error types returned by bevy's schedule.
|
//! Contains error types returned by bevy's schedule.
|
||||||
|
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
use crate::{component::ComponentId, entity::Entity, schedule::InternedScheduleLabel};
|
use crate::{component::ComponentId, entity::Entity, schedule::InternedScheduleLabel};
|
||||||
|
|
||||||
/// The error type returned by [`World::try_run_schedule`] if the provided schedule does not exist.
|
/// The error type returned by [`World::try_run_schedule`] if the provided schedule does not exist.
|
||||||
///
|
///
|
||||||
/// [`World::try_run_schedule`]: crate::world::World::try_run_schedule
|
/// [`World::try_run_schedule`]: crate::world::World::try_run_schedule
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
#[error("The schedule with the label {0:?} was not found.")]
|
#[display("The schedule with the label {_0:?} was not found.")]
|
||||||
|
#[error(ignore)]
|
||||||
pub struct TryRunScheduleError(pub InternedScheduleLabel);
|
pub struct TryRunScheduleError(pub InternedScheduleLabel);
|
||||||
|
|
||||||
/// An error that occurs when dynamically retrieving components from an entity.
|
/// An error that occurs when dynamically retrieving components from an entity.
|
||||||
#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Error, Display, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum EntityComponentError {
|
pub enum EntityComponentError {
|
||||||
/// The component with the given [`ComponentId`] does not exist on the entity.
|
/// The component with the given [`ComponentId`] does not exist on the entity.
|
||||||
#[error("The component with ID {0:?} does not exist on the entity.")]
|
#[display("The component with ID {_0:?} does not exist on the entity.")]
|
||||||
|
#[error(ignore)]
|
||||||
MissingComponent(ComponentId),
|
MissingComponent(ComponentId),
|
||||||
/// The component with the given [`ComponentId`] was requested mutably more than once.
|
/// The component with the given [`ComponentId`] was requested mutably more than once.
|
||||||
#[error("The component with ID {0:?} was requested mutably more than once.")]
|
#[display("The component with ID {_0:?} was requested mutably more than once.")]
|
||||||
|
#[error(ignore)]
|
||||||
AliasedMutability(ComponentId),
|
AliasedMutability(ComponentId),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurs when fetching entities mutably from a world.
|
/// An error that occurs when fetching entities mutably from a world.
|
||||||
#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Error, Display, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum EntityFetchError {
|
pub enum EntityFetchError {
|
||||||
/// The entity with the given ID does not exist.
|
/// The entity with the given ID does not exist.
|
||||||
#[error("The entity with ID {0:?} does not exist.")]
|
#[display("The entity with ID {_0:?} does not exist.")]
|
||||||
|
#[error(ignore)]
|
||||||
NoSuchEntity(Entity),
|
NoSuchEntity(Entity),
|
||||||
/// The entity with the given ID was requested mutably more than once.
|
/// The entity with the given ID was requested mutably more than once.
|
||||||
#[error("The entity with ID {0:?} was requested mutably more than once.")]
|
#[display("The entity with ID {_0:?} was requested mutably more than once.")]
|
||||||
|
#[error(ignore)]
|
||||||
AliasedMutability(Entity),
|
AliasedMutability(Entity),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
|
|
||||||
use thiserror::Error;
|
use derive_more::derive::{Display, Error};
|
||||||
|
|
||||||
use bevy_reflect::{Reflect, ReflectFromPtr};
|
use bevy_reflect::{Reflect, ReflectFromPtr};
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ impl World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The error type returned by [`World::get_reflect`] and [`World::get_reflect_mut`].
|
/// The error type returned by [`World::get_reflect`] and [`World::get_reflect_mut`].
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Display, Debug)]
|
||||||
pub enum GetComponentReflectError {
|
pub enum GetComponentReflectError {
|
||||||
/// There is no [`ComponentId`] corresponding to the given [`TypeId`].
|
/// There is no [`ComponentId`] corresponding to the given [`TypeId`].
|
||||||
///
|
///
|
||||||
@ -208,11 +208,14 @@ pub enum GetComponentReflectError {
|
|||||||
/// See the documentation for [`bevy_reflect`] for more information.
|
/// See the documentation for [`bevy_reflect`] for more information.
|
||||||
///
|
///
|
||||||
/// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type
|
/// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type
|
||||||
#[error("No `ComponentId` corresponding to {0:?} found (did you call App::register_type()?)")]
|
#[display(
|
||||||
|
"No `ComponentId` corresponding to {_0:?} found (did you call App::register_type()?)"
|
||||||
|
)]
|
||||||
|
#[error(ignore)]
|
||||||
NoCorrespondingComponentId(TypeId),
|
NoCorrespondingComponentId(TypeId),
|
||||||
|
|
||||||
/// The given [`Entity`] does not have a [`Component`] corresponding to the given [`TypeId`].
|
/// The given [`Entity`] does not have a [`Component`] corresponding to the given [`TypeId`].
|
||||||
#[error("The given `Entity` {entity:?} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})")]
|
#[display("The given `Entity` {entity:?} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})")]
|
||||||
EntityDoesNotHaveComponent {
|
EntityDoesNotHaveComponent {
|
||||||
/// The given [`Entity`].
|
/// The given [`Entity`].
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
@ -226,7 +229,7 @@ pub enum GetComponentReflectError {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/// The [`World`] was missing the [`AppTypeRegistry`] resource.
|
/// The [`World`] was missing the [`AppTypeRegistry`] resource.
|
||||||
#[error("The `World` was missing the `AppTypeRegistry` resource")]
|
#[display("The `World` was missing the `AppTypeRegistry` resource")]
|
||||||
MissingAppTypeRegistry,
|
MissingAppTypeRegistry,
|
||||||
|
|
||||||
/// The [`World`]'s [`TypeRegistry`] did not contain [`TypeData`] for [`ReflectFromPtr`] for the given [`TypeId`].
|
/// The [`World`]'s [`TypeRegistry`] did not contain [`TypeData`] for [`ReflectFromPtr`] for the given [`TypeId`].
|
||||||
@ -240,7 +243,8 @@ pub enum GetComponentReflectError {
|
|||||||
/// [`TypeRegistry`]: bevy_reflect::TypeRegistry
|
/// [`TypeRegistry`]: bevy_reflect::TypeRegistry
|
||||||
/// [`ReflectFromPtr`]: bevy_reflect::ReflectFromPtr
|
/// [`ReflectFromPtr`]: bevy_reflect::ReflectFromPtr
|
||||||
/// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type
|
/// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type
|
||||||
#[error("The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {0:?} (did you call `App::register_type()`?)")]
|
#[display("The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {_0:?} (did you call `App::register_type()`?)")]
|
||||||
|
#[error(ignore)]
|
||||||
MissingReflectFromPtrTypeData(TypeId),
|
MissingReflectFromPtrTypeData(TypeId),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user