Skip to content

Commit

Permalink
Merge pull request #374 from permaweb/twilson63/refactor-coroutine-re…
Browse files Browse the repository at this point in the history
…sume

refactor: coroutine resume to bubble up errors
  • Loading branch information
twilson63 authored Oct 17, 2024
2 parents 8457db4 + 3153e94 commit 0d2fae5
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 0d2fae5

Please sign in to comment.