wibox.widget.base: Use assert() instead of error()
This means you now get a backtrace (traceback?) that helps identifying the faulty code. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
1f95825a1e
commit
f1fd4a52a1
|
@ -4,9 +4,9 @@
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local debug = require("gears.debug")
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local error = error
|
|
||||||
local type = type
|
local type = type
|
||||||
local table = table
|
local table = table
|
||||||
|
|
||||||
|
@ -106,19 +106,14 @@ end
|
||||||
--- Do some sanity checking on widget. This function raises a lua error if
|
--- Do some sanity checking on widget. This function raises a lua error if
|
||||||
-- widget is not a valid widget.
|
-- widget is not a valid widget.
|
||||||
function check_widget(widget)
|
function check_widget(widget)
|
||||||
if type(widget) ~= "table" then
|
debug.assert(type(widget) == "table")
|
||||||
error("widget is not a table?!")
|
|
||||||
end
|
|
||||||
for k, func in pairs({ "draw", "fit", "add_signal", "connect_signal", "disconnect_signal" }) do
|
for k, func in pairs({ "draw", "fit", "add_signal", "connect_signal", "disconnect_signal" }) do
|
||||||
if type(widget[func]) ~= "function" then
|
debug.assert(type(widget[func]) == "function", func .. " is not a function")
|
||||||
error("widget's " .. func .. "() is not a function?!")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local width, height = widget:fit(0, 0)
|
local width, height = widget:fit(0, 0)
|
||||||
if type(width) ~= "number" or type(height) ~= "number" then
|
debug.assert(type(width) == "number")
|
||||||
error("widget's fit() didn't return two numbers")
|
debug.assert(type(height) == "number")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue