Skip to content

Conversation

@mrchantey
Copy link
Contributor

main branch version of #22444

The new 0.18 entity errors feel a bit 'inside baseball' for end-users, for instance interacting with a despawned entity makes no mention of the entity not being spawned:

let mut world = World::new();
let entity = world.spawn_empty().id();
world.entity_mut(entity).despawn();
world.entity(entity);

// Panic: The entity with ID 27v0 is invalid; its index now has generation 1.

Ideally I'd like to implement proper rust-style errors with a short paragraph detailing common causes and links to docs but thats a bigger discussion.

At least for 0.18 i think this very common error needs a prefix Entity Not Spawned:

  • Before: The entity with ID 27v0 is invalid; its index now has generation 1.
  • After: Entity Not Spawned: The entity with ID 27v0 is invalid; its index now has generation 1.

Copy link
Contributor

@HugoPeters1024 HugoPeters1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! You make a valid point and this is a good solution

@kfc35 kfc35 added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Jan 10, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 11, 2026
Merged via the queue into bevyengine:main with commit b1d1b2c Jan 11, 2026
47 checks passed
alice-i-cecile pushed a commit that referenced this pull request Jan 13, 2026
main branch version of #22444

The new `0.18` entity errors feel a bit 'inside baseball' for end-users,
for instance interacting with a despawned entity makes no mention of the
entity not being spawned:

```rust
let mut world = World::new();
let entity = world.spawn_empty().id();
world.entity_mut(entity).despawn();
world.entity(entity);

// Panic: The entity with ID 27v0 is invalid; its index now has generation 1.

```
Ideally I'd like to implement proper rust-style errors with a short
paragraph detailing common causes and links to docs but thats a bigger
discussion.

At least for `0.18` i think this very common error needs a prefix
`Entity Not Spawned:`

- Before: `The entity with ID 27v0 is invalid; its index now has
generation 1.`
- After: `Entity Not Spawned: The entity with ID 27v0 is invalid; its
index now has generation 1.`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants