From 64a81ebf7a552df35924d90d2f132d09af658f35 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 23 Jan 2015 21:51:29 +0100 Subject: [PATCH] make error messages more useful for nodebox lookups --- homedecor/nodeboxes.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/homedecor/nodeboxes.lua b/homedecor/nodeboxes.lua index fe15a97d..11a04fe0 100644 --- a/homedecor/nodeboxes.lua +++ b/homedecor/nodeboxes.lua @@ -21,14 +21,17 @@ homedecor.nodebox = { local mt = {} mt.__index = function(table, key) local ref = homedecor.box[key] - if type(ref) == "function" then + local ref_type = type(ref) + if ref_type == "function" then return function(...) return { type = "fixed", fixed = ref(...) } end - elseif type(ref) == "table" then + elseif ref_type == "table" then return { type = "fixed", fixed = ref } + elseif ref_type == "nil" then + error(key .. "could not be found among nodebox presets and functions") end - error("unexpected datatype " .. tostring(type(ref))) + error("unexpected datatype " .. tostring(type(ref)) .. " while looking for " .. key) end setmetatable(homedecor.nodebox, mt)