Skip to content

Commit 7b937dc

Browse files
committed
Use pcall to capture errors
If a user-created setup or teardown had an error, it would stop all headspace execution, preventing the rest of the lifecycle from completing.
1 parent 6681eff commit 7b937dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ m.switch = function(space)
253253
-- teardown the previous space
254254
if previousSpace then
255255
if m.hasFunc(previousSpace.funcs, 'teardown') then
256-
m.config.funcs[previousSpace.funcs].teardown()
256+
pcall(m.config.funcs[previousSpace.funcs].teardown)
257257
end
258258

259259
if previousSpace.layouts then
@@ -308,7 +308,7 @@ m.switch = function(space)
308308

309309
-- run setup()
310310
if m.hasFunc(space.funcs, 'setup') then
311-
m.config.funcs[space.funcs].setup()
311+
pcall(m.config.funcs[space.funcs].setup)
312312
end
313313

314314
-- use layout

0 commit comments

Comments
 (0)