Merge branch 'better-error-handling'
Closes https://github.com/awesomeWM/awesome/pull/311
This commit is contained in:
commit
5a9ec82b95
15
event.c
15
event.c
|
@ -116,11 +116,11 @@ event_handle_mousegrabber(int x, int y, uint16_t mask)
|
||||||
if(globalconf.mousegrabber != LUA_REFNIL)
|
if(globalconf.mousegrabber != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
lua_State *L = globalconf_get_lua_State();
|
lua_State *L = globalconf_get_lua_State();
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, globalconf.mousegrabber);
|
|
||||||
mousegrabber_handleevent(L, x, y, mask);
|
mousegrabber_handleevent(L, x, y, mask);
|
||||||
if(lua_pcall(L, 1, 1, 0))
|
lua_rawgeti(L, LUA_REGISTRYINDEX, globalconf.mousegrabber);
|
||||||
|
if(!luaA_dofunction(L, 1, 1))
|
||||||
{
|
{
|
||||||
warn("error running function: %s", lua_tostring(L, -1));
|
warn("Stopping mousegrabber.");
|
||||||
luaA_mousegrabber_stop(L);
|
luaA_mousegrabber_stop(L);
|
||||||
}
|
}
|
||||||
else if(!lua_isboolean(L, -1) || !lua_toboolean(L, -1))
|
else if(!lua_isboolean(L, -1) || !lua_toboolean(L, -1))
|
||||||
|
@ -599,16 +599,17 @@ event_handle_key(xcb_key_press_event_t *ev)
|
||||||
|
|
||||||
if(globalconf.keygrabber != LUA_REFNIL)
|
if(globalconf.keygrabber != LUA_REFNIL)
|
||||||
{
|
{
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, globalconf.keygrabber);
|
|
||||||
if(keygrabber_handlekpress(L, ev))
|
if(keygrabber_handlekpress(L, ev))
|
||||||
{
|
{
|
||||||
if(lua_pcall(L, 3, 1, 0))
|
lua_rawgeti(L, LUA_REGISTRYINDEX, globalconf.keygrabber);
|
||||||
|
|
||||||
|
if(!luaA_dofunction(L, 3, 1))
|
||||||
{
|
{
|
||||||
warn("error running function: %s", lua_tostring(L, -1));
|
warn("Stopping keygrabber.");
|
||||||
luaA_keygrabber_stop(L);
|
luaA_keygrabber_stop(L);
|
||||||
}
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
lua_pop(L, 1); /* pop returned value or function if not called */
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,9 +20,9 @@ local keygrabbing = false
|
||||||
|
|
||||||
|
|
||||||
local function grabber(mod, key, event)
|
local function grabber(mod, key, event)
|
||||||
for i, g in ipairs(grabbers) do
|
for i, keygrabber_function in ipairs(grabbers) do
|
||||||
-- continue if the grabber explicitly returns false
|
-- continue if the grabber explicitly returns false
|
||||||
if g(mod, key, event) ~= false then
|
if keygrabber_function(mod, key, event) ~= false then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -161,8 +161,8 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
|
||||||
-- Add a delayed callback for the first update.
|
-- Add a delayed callback for the first update.
|
||||||
if not queued_update then
|
if not queued_update then
|
||||||
timer.delayed_call(function()
|
timer.delayed_call(function()
|
||||||
|
queued_update = false
|
||||||
tasklist_update(screen, w, buttons, filter, data, style, uf)
|
tasklist_update(screen, w, buttons, filter, data, style, uf)
|
||||||
queued_update = nil
|
|
||||||
end)
|
end)
|
||||||
queued_update = true
|
queued_update = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -103,7 +103,8 @@ function beautiful.init(config)
|
||||||
if type(config) == 'string' then
|
if type(config) == 'string' then
|
||||||
-- Expand the '~' $HOME shortcut
|
-- Expand the '~' $HOME shortcut
|
||||||
config = config:gsub("^~/", homedir .. "/")
|
config = config:gsub("^~/", homedir .. "/")
|
||||||
success, theme = pcall(function() return dofile(config) end)
|
success, theme = xpcall(function() return dofile(config) end,
|
||||||
|
debug.traceback)
|
||||||
elseif type(config) == 'table' then
|
elseif type(config) == 'table' then
|
||||||
success = true
|
success = true
|
||||||
theme = config
|
theme = config
|
||||||
|
|
|
@ -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)
|
end, function(err)
|
||||||
if not success then
|
print(debug.traceback("Error during executing timeout handler: "..tostring(err)))
|
||||||
print(message)
|
end)
|
||||||
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)
|
||||||
|
|
5
luaa.h
5
luaa.h
|
@ -56,6 +56,9 @@ luaA_warn(lua_State *L, const char *fmt, ...)
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
luaL_traceback(L, L, NULL, 2);
|
||||||
|
fprintf(stderr, "%s\n", lua_tostring(L, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
@ -63,6 +66,8 @@ luaA_typerror(lua_State *L, int narg, const char *tname)
|
||||||
{
|
{
|
||||||
const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
||||||
tname, luaL_typename(L, narg));
|
tname, luaL_typename(L, narg));
|
||||||
|
luaL_traceback(L, L, NULL, 2);
|
||||||
|
lua_concat(L, 2);
|
||||||
return luaL_argerror(L, narg, msg);
|
return luaL_argerror(L, narg, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,9 @@ runner.run_steps = function(steps)
|
||||||
local step_as_string = step..'/'..#steps..' (@'..step_count..')'
|
local step_as_string = step..'/'..#steps..' (@'..step_count..')'
|
||||||
|
|
||||||
-- Call the current step's function.
|
-- Call the current step's function.
|
||||||
local success, result = pcall(steps[step], step_count)
|
local success, result = xpcall(function()
|
||||||
|
return steps[step](step_count)
|
||||||
|
end, debug.traceback)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
io.stderr:write('Error: running function for step '
|
io.stderr:write('Error: running function for step '
|
||||||
|
|
Loading…
Reference in New Issue