aboutsummaryrefslogtreecommitdiffhomepage
path: root/init.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-02 14:12:47 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-02 14:12:47 -0400
commite423fbee442e89a93846dd801b0d2786d72e27bd (patch)
treed5341e80bed6ed1c82fffaee6c578c97d7a90f5e /init.lua
parent375d0e6b94781156a76682d39b89db507b5d24cd (diff)
Handle startup errors more nicely.
This also prevents a crash on exit in some circumstances, due to mismatched metatables.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index ff283986..0b923158 100644
--- a/init.lua
+++ b/init.lua
@@ -321,7 +321,13 @@ buffer.accessibility = buffer.ACCESSIBILITY_DISABLED
-- Load user init file, which may also define default buffer settings.
local user_init = _USERHOME .. '/init.lua'
-if lfs.attributes(user_init) then dofile(user_init) end
+if lfs.attributes(user_init) then
+ local ok, errmsg = pcall(dofile, user_init)
+ if not ok then
+ events.connect(
+ events.INITIALIZED, function() events.emit(events.ERROR, errmsg) end)
+ end
+end
-- Generate default buffer settings for subsequent buffers and remove temporary
-- buffer metatable listener.