{"record":{"id":"5e53d4c30ac28743","repo":"bevyengine/bevy","slug":"could-not-despawn-entity-0","errorCode":null,"errorMessage":"Could not despawn entity: {0}","messagePattern":"Could not despawn entity: (.+?)","errorType":"exception","errorClass":"EntityDespawnError","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/world/error.rs","lineNumber":35,"sourceCode":"pub struct TryRunScheduleError(pub InternedScheduleLabel);\n\n/// The error type returned by [`World::try_insert_batch`] and [`World::try_insert_batch_if_new`]\n/// if any of the provided entities do not exist.\n///\n/// [`World::try_insert_batch`]: crate::world::World::try_insert_batch\n/// [`World::try_insert_batch_if_new`]: crate::world::World::try_insert_batch_if_new\n#[derive(thiserror::Error, Debug, Clone)]\n#[error(\"Could not insert bundles of type {bundle_type} into the entities with the following IDs because they do not exist: {entities:?}\")]\npub struct TryInsertBatchError {\n    /// The bundles' type name.\n    pub bundle_type: DebugName,\n    /// The IDs of the provided entities that do not exist.\n    pub entities: Vec<Entity>,\n}\n\n/// An error that occurs when a specified [`Entity`] could not be despawned.\n#[derive(thiserror::Error, Debug, Clone, Copy)]\n#[error(\"Could not despawn entity: {0}\")]\npub struct EntityDespawnError(#[from] pub EntityNotSpawnedError);\n\n/// An error that occurs when dynamically retrieving components from an entity.\n#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\npub enum EntityComponentError {\n    /// The component with the given [`ComponentId`] does not exist on the entity.\n    #[error(\"The component with ID {0:?} does not exist on the entity.\")]\n    MissingComponent(ComponentId),\n    /// The component with the given [`ComponentId`] was requested mutably more than once.\n    #[error(\"The component with ID {0:?} was requested mutably more than once.\")]\n    AliasedMutability(ComponentId),\n}\n\n/// An error that occurs when fetching entities mutably from a world.\n#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\npub enum EntityMutableFetchError {\n    /// The entity is not spawned.\n    #[error(","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/world/error.rs#L17-L53","documentation":"EntityDespawnError: an attempt was made to despawn (or otherwise consume) an entity that is not spawned — the id is stale or was never allocated, wrapping the underlying EntityNotSpawnedError.","triggerScenarios":"Thrown at crates/bevy_ecs/src/world/error.rs:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check world.get_entity(id) before despawning","Discard stale Entity ids after structural changes that may have despawned entities","Use try_despawn and match on the error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}