From f62fc5a039dca70219fb2b38f61fc53a2542adf7 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 5 Jan 2025 15:32:03 +0300 Subject: [PATCH] fix errors handling in event handlers --- res/scripts/stdlib.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index 791cfdf4..86bdf999 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -127,7 +127,12 @@ function events.emit(event, ...) return nil end for _, func in ipairs(handlers) do - result = result or func(...) + local status, newres = xpcall(func, __vc__error, ...) + if not status then + print("error in event ("..event..") handler: "..newres) + else + result = result or newres + end end return result end