Posted 18 June 2015 - 07:56 PM
Hi!
My problem is that I wrote a program that prints out a stacktrace of the running program if something errors, but if the window API errors, the computer just turns off with a "Goodbye" message.
My "debugger":
I can't find the location of the error in the main file, because it's really big.
Edit: is it possible to break out of the derpy window API in the multishell? Because it caused a lot of headaches because of this bug :(/>
My problem is that I wrote a program that prints out a stacktrace of the running program if something errors, but if the window API errors, the computer just turns off with a "Goodbye" message.
My "debugger":
Spoiler
local function trace(ignore, level)
level = type(level) == "number" and level
local errorLevel = 3 + (type(ignore) == "number" and ignore or 0)
local errorDiff = errorLevel
local errorPos
local result = {}
repeat
errorPos = select(2, xpcall(function() error("@", errorLevel) end, function(shit) return shit end))
if errorPos ~= nil then errorPos = errorPos:match("(.+): @") end
if errorPos then
table.insert(result, errorPos)
errorLevel = errorLevel + 1
if errorLevel - errorDiff == level then return result end
end
until not errorPos
return result
end
local function ejj(ejjdata)
print("Press a key to show error")
os.pullEvent("key")
local tracd = trace()
print(ejjdata)
for k,v in pairs(tracd) do
print("- "..v)
sleep(0.2)
end
return ejjdata--.."\n- "..table.concat(, "\n- ")
end
local function loadfunc(feil, name)
local handel = fs.open(fs.combine(feil, ""), "r")
if not handel then return false, "Unable to load "..feil end
local kernelstr = handel.readAll()
handel.close()
return loadstring(kernelstr, name)
end
local function dofunc(feil, name, err, ...)
local func, ejj = loadfunc(feil, name)
if not func then return nil, ejj end
local argz = {...}
if err then return xpcall(function() func(unpack(argz)) end, err) else return pcall(func, unpack(argz)) end
end
local argz = {...}
dofunc(argz[1], "DebuggerD", ejj, unpack(argz, 2))
I can't find the location of the error in the main file, because it's really big.
Edit: is it possible to break out of the derpy window API in the multishell? Because it caused a lot of headaches because of this bug :(/>
Edited on 18 June 2015 - 05:59 PM