pass the inject code error to debug_console

This commit is contained in:
lpy
2016-11-22 11:14:07 +08:00
parent c5fb8ef3f7
commit 708d57a77e
3 changed files with 10 additions and 5 deletions

View File

@@ -52,9 +52,9 @@ local function init(skynet, export)
function dbgcmd.RUN(source, filename)
local inject = require "skynet.inject"
local output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol)
local ok, output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol)
collectgarbage "collect"
skynet.ret(skynet.pack(table.concat(output, "\n")))
skynet.ret(skynet.pack(ok, table.concat(output, "\n")))
end
function dbgcmd.TERM(service)

View File

@@ -54,12 +54,13 @@ return function(skynet, source, filename , ...)
local env = setmetatable( { print = print , _U = u, _P = p}, { __index = _ENV })
local func, err = load(source, filename, "bt", env)
if not func then
return { err }
return false, { err }
end
local ok, err = skynet.pcall(func)
if not ok then
table.insert(output, err)
return false, output
end
return output
return true, output
end

View File

@@ -242,7 +242,11 @@ function COMMAND.inject(address, filename)
end
local source = f:read "*a"
f:close()
return skynet.call(address, "debug", "RUN", source, filename)
local ok, output = skynet.call(address, "debug", "RUN", source, filename)
if ok == false then
error(output)
end
return output
end
function COMMAND.task(address)