Skip to content

Commit

Permalink
Throw errors that make sense if we get nonnumbers for setValue (#3081)
Browse files Browse the repository at this point in the history
* Typecheck and throw errors that make sense if we get nonnumbers for setValue
  • Loading branch information
demonnic committed Sep 14, 2019
1 parent dc14cec commit 386cb4d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mudlet-lua/lua/geyser/GeyserGauge.lua
Expand Up @@ -31,6 +31,8 @@ Geyser.Gauge = Geyser.Container:new({
-- @param maxValue Maximum numeric value. Optionally nil, see above.
-- @param text The text to display on the gauge, it is optional.
function Geyser.Gauge:setValue (currentValue, maxValue, text)
assert(type(currentValue) == "number", string.format("bad argument #1 type (currentValue as number expected, got %s!)", type(currentValue)))
assert(maxValue == nil or type(maxValue) == "number", string.format("bad argument #2 type (optional maxValue as number expected, got %s!)", type(maxValue)))
-- Use sensible defaults for missing parameters.
if currentValue < 0 then
currentValue = 0
Expand Down

0 comments on commit 386cb4d

Please sign in to comment.