fix errors handling in event handlers

This commit is contained in:
MihailRis 2025-01-05 15:32:03 +03:00
parent 490cae74f5
commit f62fc5a039

View File

@ -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