Error Handling

This commit is contained in:
Noella
2024-03-04 16:20:31 -07:00
parent 11146d6177
commit 3f676b7b00
2 changed files with 25 additions and 24 deletions

24
main/error_handling.lua Normal file
View File

@@ -0,0 +1,24 @@
local naughty = require("naughty")
-- 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

25
rc.lua
View File

@@ -18,30 +18,7 @@ local hotkeys_popup = require("awful.hotkeys_popup")
-- 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")
-- {{{ Error handling require("main.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.