Skip to content

Commit

Permalink
refactor: coroutine resume to bubble up errors
Browse files Browse the repository at this point in the history
  • Loading branch information
twilson63 committed Oct 17, 2024
1 parent c883591 commit 3153e94
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion process/handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ end
function handlers.receive(pattern)
local self = coroutine.running()
handlers.once(pattern, function (msg)
coroutine.resume(self, msg)
-- If the result of the resumed coroutine is an error then we should bubble it up to the process
local _, success, errmsg = coroutine.resume(self, msg)
if not success then
error(errmsg)
end
end)
return coroutine.yield(pattern)
end
Expand Down

0 comments on commit 3153e94

Please sign in to comment.