mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 11:44:08 +00:00
refactor: error for effect cleanup errors
This commit is contained in:
parent
c52f55a55e
commit
748dbc5014
1 changed files with 11 additions and 3 deletions
|
|
@ -178,6 +178,9 @@ end
|
|||
@param cleanups List of cleanup functions
|
||||
]]
|
||||
local function runCleanups(cleanups: { Cleanup })
|
||||
local hasErrors = false
|
||||
local errors = {}
|
||||
|
||||
for index, cleanup in cleanups do
|
||||
cleanups[index] = nil
|
||||
|
||||
|
|
@ -186,9 +189,14 @@ local function runCleanups(cleanups: { Cleanup })
|
|||
activeSub = prevSub
|
||||
|
||||
if not success then
|
||||
warn("Error occurred during effect cleanup:", result)
|
||||
hasErrors = true
|
||||
table.insert(errors, tostring(result))
|
||||
end
|
||||
end
|
||||
|
||||
if hasErrors then
|
||||
error(`Errors occurred during effect cleanup:\n\n${table.concat(errors, "\n\n")}`, 0)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
|
|
@ -404,14 +412,14 @@ local function notify(effect: ReactiveNode)
|
|||
queuedLength = insertIndex
|
||||
|
||||
-- Reverse the collected effects to ensure outer effects run first
|
||||
while true do
|
||||
repeat
|
||||
insertIndex -= 1
|
||||
if firstInsertedIndex >= insertIndex then
|
||||
break
|
||||
end
|
||||
queued[firstInsertedIndex], queued[insertIndex] = queued[insertIndex], queued[firstInsertedIndex]
|
||||
firstInsertedIndex += 1
|
||||
end
|
||||
until false
|
||||
end
|
||||
|
||||
--[[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue