diff --git a/api/api.lua b/api/api.lua index e2850c1a..1d146e46 100644 --- a/api/api.lua +++ b/api/api.lua @@ -1494,13 +1494,10 @@ end -- return object function pfUI.api.GetNoNameObject(frame, objtype, layer, arg1, arg2) -- A nil/non-frame parent otherwise dies on frame:GetRegions()/:GetChildren() - -- below, and the traceback stops here — useless, since all callers share this - -- line. pfUI shadows Lua's `error` (dropping the level arg and not throwing), - -- so fold the caller frame in via debugstack to name the offending skin, then - -- bail so we don't fall through and crash on frame:GetRegions() anyway. + -- below, where the message would name this line, shared by every caller; + -- level 2 names the offending skin instead. if type(frame) ~= "table" or not frame.GetRegions then - error("GetNoNameObject: invalid parent frame\n" .. debugstack(2, 3, 0)) - return + error("GetNoNameObject: invalid parent frame", 2) end local arg1 = arg1 and gsub(arg1, "([%+%-%*%(%)%?%[%]%^])", "%%%1") diff --git a/pfUI.lua b/pfUI.lua index ea9d3d0d..db67b8e3 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -461,15 +461,20 @@ message = function(msg) end print = print or message -error = function(msg) - if PF_DEBUG_MODE then message(debugstack()) end - if string.find(msg, "AddOns\\pfUI") then - DEFAULT_CHAT_FRAME:AddMessage("|cffcc3333ERROR: |cffff5555".. (msg or "nil" )) - elseif not pfUI_config or (pfUI_config.global and pfUI_config.global.errors == "1") then - DEFAULT_CHAT_FRAME:AddMessage("|cffcc3333ERROR: |cffff5555".. (msg or "nil" )) +-- Errors print to chat: pfUI's own always, other addons' when the errors +-- option is on. In debug mode the stack follows, starting at the code that +-- raised the error rather than at this handler. +seterrorhandler(function(msg) + msg = tostring(msg) + if PF_DEBUG_MODE then + local height = GetErrorCallstackHeight() + message(height and debugstack(GetCallstackHeight() - height + 1) or debugstack(2)) end -end -seterrorhandler(error) + if string.find(msg, "AddOns\\pfUI") or not pfUI_config + or (pfUI_config.global and pfUI_config.global.errors == "1") then + DEFAULT_CHAT_FRAME:AddMessage("|cffcc3333ERROR: |cffff5555" .. msg) + end +end) function pfUI.SetupCVars() ClearTutorials()