Skip to content

Commit

Permalink
Improve debug message
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Sep 21, 2024
1 parent 5d6c2e8 commit 74ca305
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1666,16 +1666,14 @@ if _G.__JECS_DEBUG then
return
end



if world_has_one_inline(world, entity, id) then
if invoked_hook then
local file, line = debug.info(2, "sl")
local hook_fn = `{file}::{line}`
throw(
([[cannot call world:set within the
This world:set function invokes a structural change because %s doesn't exist on the entity.\n
call world:add when the hook %s is in process]]):format(get_name(world, id), hook_fn))
local why = `cannot call world:set inside {hook_fn} because it adds the component {get_name(world, id)}`
why ..= `\n[jecs note]: consider handling this logic inside of a system`
throw(why)
return
end
end

Expand Down

0 comments on commit 74ca305

Please sign in to comment.