Attach debugger on nil return value
This commit is contained in:
parent
407082dd2c
commit
0ff986a4f2
@ -2,6 +2,7 @@ local Inventory = require("storage.inventory")
|
|||||||
local Sentinel = require("storage.sentinel")
|
local Sentinel = require("storage.sentinel")
|
||||||
local Logging = require("logging")
|
local Logging = require("logging")
|
||||||
local Logger = Logging.getGlobalLogger()
|
local Logger = Logging.getGlobalLogger()
|
||||||
|
local Debugger = require("debugger")
|
||||||
|
|
||||||
local ItemStack = Sentinel:tag({}, Sentinel.ITEMSTACK)
|
local ItemStack = Sentinel:tag({}, Sentinel.ITEMSTACK)
|
||||||
ItemStack.__index = ItemStack
|
ItemStack.__index = ItemStack
|
||||||
@ -199,7 +200,12 @@ function ItemStack:transferTo(target, count)
|
|||||||
return count == 0, 0
|
return count == 0, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local result = { pcall(self:getInventory().pushItems, peripheral.getName(target:getInventory()), self:getSlot(), cap, target:getSlot()) }
|
local errC = 0
|
||||||
|
local result
|
||||||
|
repeat
|
||||||
|
result = { pcall(self:getInventory().pushItems, peripheral.getName(target:getInventory()), self:getSlot(), cap, target:getSlot()) }
|
||||||
|
errC = errC + 1
|
||||||
|
until (not result[1]) or (result[2] ~= nil) or (errC > 8)
|
||||||
|
|
||||||
if not result[1] then
|
if not result[1] then
|
||||||
return false, result[2]
|
return false, result[2]
|
||||||
@ -207,13 +213,19 @@ function ItemStack:transferTo(target, count)
|
|||||||
|
|
||||||
if result[2] == nil then
|
if result[2] == nil then
|
||||||
Logger:error(
|
Logger:error(
|
||||||
"Error transferring item", self:getInventory().pushItems, Logger.plain("\n"),
|
"Error transferring item", self:getInventory().pushItems, "\n",
|
||||||
peripheral.getName(target:getInventory()), Logger.plain("\n"),
|
peripheral.getName(target:getInventory()), "\n",
|
||||||
cap, Logger.plain("\n"),
|
errC, "\n",
|
||||||
self, Logger.plain("\n"),
|
cap, "\n",
|
||||||
target, Logger.plain("\n"),
|
self, "\n",
|
||||||
|
target, "\n",
|
||||||
|
target:getInventory().getItemLimit(target:getSlot()), "\n",
|
||||||
result
|
result
|
||||||
)
|
)
|
||||||
|
local errorCond = Debugger.debugREPL(function(retval)
|
||||||
|
Logger:error("->", retval)
|
||||||
|
end)
|
||||||
|
Logger:error("x>", errorCond)
|
||||||
end
|
end
|
||||||
|
|
||||||
target:_modify(result[2], self)
|
target:_modify(result[2], self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user