From 3153e94859af726240a88879ba4422e6a45e26b2 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Thu, 17 Oct 2024 15:32:04 +0000 Subject: [PATCH] refactor: coroutine resume to bubble up errors --- process/handlers.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/process/handlers.lua b/process/handlers.lua index 7708f29d..eb58e9ee 100644 --- a/process/handlers.lua +++ b/process/handlers.lua @@ -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