Improve error handling in craftItem function with pcall for safer execution
This commit is contained in:
@@ -3213,7 +3213,12 @@ local function main()
|
||||
pcall(broadcastState)
|
||||
elseif message.type == "craft" and message.recipeIdx then
|
||||
print(string.format("[NET] Craft request: recipe #%d", message.recipeIdx))
|
||||
local ok, err = craftItem(message.recipeIdx)
|
||||
local pok, ok, err = pcall(craftItem, message.recipeIdx)
|
||||
if not pok then
|
||||
print("[NET] craftItem crashed: " .. tostring(ok))
|
||||
err = tostring(ok)
|
||||
ok = false
|
||||
end
|
||||
networkModem.transmit(replyChannel, ORDER_CHANNEL, {
|
||||
type = "craft_result",
|
||||
success = ok,
|
||||
|
||||
Reference in New Issue
Block a user