mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
fix errors handling in event handlers
This commit is contained in:
parent
490cae74f5
commit
f62fc5a039
1 changed files with 6 additions and 1 deletions
|
|
@ -127,7 +127,12 @@ function events.emit(event, ...)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
for _, func in ipairs(handlers) do
|
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
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue