[AWESOME] Refactor error_handling
This commit is contained in:
parent
8ed6041aa1
commit
4a8eecbc39
2 changed files with 40 additions and 33 deletions
39
configs/awesome/error_handling.lua
Normal file
39
configs/awesome/error_handling.lua
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
-- Notification library
|
||||||
|
local naughty = require("naughty")
|
||||||
|
|
||||||
|
local function init(awesome)
|
||||||
|
-- {{{ Error handling
|
||||||
|
-- Check if awesome encountered an error during startup and fell back to
|
||||||
|
-- another config (This code will only ever execute for the fallback config)
|
||||||
|
if awesome.startup_errors then
|
||||||
|
naughty.notify({
|
||||||
|
preset = naughty.config.presets.critical,
|
||||||
|
title = "Oops, there were errors during startup!",
|
||||||
|
text = awesome.startup_errors
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Handle runtime errors after startup
|
||||||
|
do
|
||||||
|
local in_error = false
|
||||||
|
awesome.connect_signal("debug::error", function(err)
|
||||||
|
-- Make sure we don't go into an endless error loop
|
||||||
|
if in_error then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
in_error = true
|
||||||
|
|
||||||
|
naughty.notify({
|
||||||
|
preset = naughty.config.presets.critical,
|
||||||
|
title = "Oops, an error happened!",
|
||||||
|
text = tostring(err)
|
||||||
|
})
|
||||||
|
in_error = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
init = init
|
||||||
|
}
|
|
@ -10,44 +10,12 @@ require("awful.autofocus")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
-- Theme handling library
|
-- Theme handling library
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
-- Notification library
|
|
||||||
local naughty = require("naughty")
|
|
||||||
local menubar = require("menubar")
|
local menubar = require("menubar")
|
||||||
local hotkeys_popup = require("awful.hotkeys_popup")
|
local hotkeys_popup = require("awful.hotkeys_popup")
|
||||||
-- Enable hotkeys help widget for VIM and other apps
|
-- Enable hotkeys help widget for VIM and other apps
|
||||||
-- when client with a matching name is opened:
|
-- when client with a matching name is opened:
|
||||||
require("awful.hotkeys_popup.keys")
|
require("awful.hotkeys_popup.keys")
|
||||||
|
require("error_handling").init(awesome)
|
||||||
-- {{{ Error handling
|
|
||||||
-- Check if awesome encountered an error during startup and fell back to
|
|
||||||
-- another config (This code will only ever execute for the fallback config)
|
|
||||||
if awesome.startup_errors then
|
|
||||||
naughty.notify({
|
|
||||||
preset = naughty.config.presets.critical,
|
|
||||||
title = "Oops, there were errors during startup!",
|
|
||||||
text = awesome.startup_errors
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Handle runtime errors after startup
|
|
||||||
do
|
|
||||||
local in_error = false
|
|
||||||
awesome.connect_signal("debug::error", function(err)
|
|
||||||
-- Make sure we don't go into an endless error loop
|
|
||||||
if in_error then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
in_error = true
|
|
||||||
|
|
||||||
naughty.notify({
|
|
||||||
preset = naughty.config.presets.critical,
|
|
||||||
title = "Oops, an error happened!",
|
|
||||||
text = tostring(err)
|
|
||||||
})
|
|
||||||
in_error = false
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
-- {{{ Variable definitions
|
-- {{{ Variable definitions
|
||||||
-- Themes define colours, icons, font and wallpapers.
|
-- Themes define colours, icons, font and wallpapers.
|
||||||
|
|
Loading…
Reference in a new issue