Removed Functions -- More useful errors
complete
Nexii Malthus
Would it be possible to make it so that if a scripter tries to access ll.SetTimerEvent / ll.SetMemoryLimit etc we would get a more useful error?
Note that we shouldn't have noop functions as these would show up while enumerating ll.*
---
Something akin to this using inheritance or metamethods: (whichever is more performant / doesnt cause a perf penalty; you're the language guru)
local RemovedTimerFunctions = { "SetTimerEvent" }
local RemovedTimeFunctions = { "ResetTime", "GetAndResetTime" }
ll = setmetatable(ll, {
__index = function(table, key)
if table.find(RemovedTimerFunctions, key) then
error("This function has been removed, please use LLTimers instead", 1)
elseif table.find(RemovedTimeFunctions, key) then
error("This function has been removed due to a conflict with LLTimers", 1)
end
end
})
ll.SetTimerEvent(0.5)
Log In
H
Harold Linden
marked this post as
complete
Just made them
nil
so nobody gets confused by iterating ll
and thinking these are actual functions that we still provide. Thanks again!H
Harold Linden
Okay, they're printing a better error message now. Now that I think more about it, you're right that having them live on
ll
doesn't provide much value at all and makes a headache for people trying to reason about the environment. I'll just remove em in the next release.H
Harold Linden
marked this post as
inĀ progress
Thanks for sending this in!
There are actually more useful error messages, but my tests were just checking that the functions errored, not that they gave the expected error ("tried to call a table is not helpful). I'll fix that up.
I don't think we'd use an
__index
because there is a perf penalty there, but we do intend to throw an error when you try to call them.H
Harold Linden
Okay yep, I was accidentally setting those functions to the
ll
module table object, and the error I was catching was just due to trying to call a table. Should be fixed with the next release, thanks again!