From cc13870fd9b0767fb1b5da85c2542e07649e0cf7 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Tue, 30 Apr 2024 16:17:51 +0200 Subject: [PATCH] Provide better error messages --- lib/init.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/init.lua b/lib/init.lua index 26ac04b..9a8f986 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -198,7 +198,7 @@ export type World = typeof(World.new()) local function ensureArchetype(world: World, types, prev) if #types < 1 then - + return world.ROOT_ARCHETYPE end local ty = hash(types) local archetype = world.archetypeIndex[ty] @@ -350,17 +350,22 @@ local function noop(): any end end +local NO_POOLS = "No components provided" + local function getSmallestMap(componentIndex, components) local s: any for i, componentId in components do local map = componentIndex[componentId] + if not map then + error(tostring(componentId).." has not been added to any entity") + end if s == nil or map.size < s.size then s = map end end - return s and s.sparse or nil + return if s then s.sparse else error(NO_POOLS) end function World.query(world: World, ...: i53): any