From e423fbee442e89a93846dd801b0d2786d72e27bd Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Fri, 2 Oct 2020 14:12:47 -0400 Subject: Handle startup errors more nicely. This also prevents a crash on exit in some circumstances, due to mismatched metatables. --- init.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'init.lua') 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. -- cgit v1.2.3