Skip to main content

azalea/client_impl/
error.rs

1use bevy_ecs::entity::Entity;
2use thiserror::Error;
3
4/// An error that occurs when we tried to access data from an entity that it
5/// doesn't have.
6///
7/// This could happen because the data does not occur for this type of entity,
8/// or because the entity is not currently loaded.
9///
10/// If this error happened when trying to access data on a client, then it may
11/// be because the client isn't currently in a world.
12///
13/// As an alias for `Result<T, MissingComponentError>`, you may use
14/// [`AzaleaResult`]. Using the `eyre` or `anyhow` crates may also simplify
15/// error handling in your bots.
16#[derive(Error, Debug)]
17#[error("{entity_description} {entity} is missing a required component: '{component}'")]
18pub struct MissingComponentError {
19    /// Should be "Entity" or "Client"
20    pub entity_description: &'static str,
21    pub entity: Entity,
22    pub component: &'static str,
23}
24
25/// An error that occurs when we tried to access data from an entity that it
26/// doesn't have.
27///
28/// See [`MissingComponentError`] for more details.
29pub type AzaleaResult<T> = Result<T, MissingComponentError>;