gears.timer: use xpcall with timeout and delayed calls
This provides a traceback in case of errors. Ref: https://github.com/awesomeWM/awesome/issues/301
This commit is contained in:
parent
aca856b5d2
commit
dc9295d981
|
@ -37,12 +37,11 @@ function timer:start()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.data.source_id = glib.timeout_add(glib.PRIORITY_DEFAULT, self.data.timeout * 1000, function()
|
self.data.source_id = glib.timeout_add(glib.PRIORITY_DEFAULT, self.data.timeout * 1000, function()
|
||||||
local success, message = pcall(function()
|
local success, message = xpcall(function()
|
||||||
self:emit_signal("timeout")
|
self:emit_signal("timeout")
|
||||||
|
end, function(err)
|
||||||
|
print(debug.traceback("Error during executing timeout handler: "..tostring(err)))
|
||||||
end)
|
end)
|
||||||
if not success then
|
|
||||||
print(message)
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -107,10 +106,11 @@ end
|
||||||
local delayed_calls = {}
|
local delayed_calls = {}
|
||||||
capi.awesome.connect_signal("refresh", function()
|
capi.awesome.connect_signal("refresh", function()
|
||||||
for _, callback in ipairs(delayed_calls) do
|
for _, callback in ipairs(delayed_calls) do
|
||||||
local success, message = pcall(unpack(callback))
|
local success, message = xpcall(function()
|
||||||
if not success then
|
callback[1](unpack(callback, 2))
|
||||||
print(message)
|
end, function(err)
|
||||||
end
|
print(debug.traceback("Error during delayed call: "..tostring(err)))
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
delayed_calls = {}
|
delayed_calls = {}
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue