Skip to content

feat: improve errors when entity is unavailable #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: improve errors when entity is unavailable
  • Loading branch information
makspll committed Apr 5, 2025
commit 94462123d84a4888eab8762c80e3c9cf1242215c
2 changes: 1 addition & 1 deletion assets/tests/insert_children/invalid_entity_errors.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local fake_entity = Entity.from_raw(9999)
local fake_entity = Entity.from_raw(0)

assert_throws(function()
world.insert_children(fake_entity, 1, {fake_entity})
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/insert_children/invalid_entity_errors.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let fake_entity = Entity.from_raw.call(9999);
let fake_entity = Entity.from_raw.call(0);

assert_throws(||{
world.insert_children.call(fake_entity, 0, [fake_entity]);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_mod_scripting_core/src/bindings/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl<'w> WorldAccessGuard<'w> {
/// checks if a given entity exists and is valid
pub fn is_valid_entity(&self, entity: Entity) -> Result<bool, InteropError> {
let cell = self.as_unsafe_world_cell()?;
Ok(cell.get_entity(entity).is_some())
Ok(cell.get_entity(entity).is_some() && entity.index() != 0)
}

/// Tries to call a fitting overload of the function with the given name and in the type id's namespace based on the arguments provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ impl IntoMarkdown for SectionItem<'_> {
</div>
"#.trim(),
);
builder.append("\n\n");
}

// we don't escape this, this is already markdown
Expand Down
Loading