From 708d57a77e01a11389c7b18621a514e1dac6ab54 Mon Sep 17 00:00:00 2001 From: lpy Date: Tue, 22 Nov 2016 11:14:07 +0800 Subject: [PATCH] pass the inject code error to debug_console --- lualib/skynet/debug.lua | 4 ++-- lualib/skynet/inject.lua | 5 +++-- service/debug_console.lua | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lualib/skynet/debug.lua b/lualib/skynet/debug.lua index 8bc999c6..e267b9a9 100644 --- a/lualib/skynet/debug.lua +++ b/lualib/skynet/debug.lua @@ -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) diff --git a/lualib/skynet/inject.lua b/lualib/skynet/inject.lua index 3c87bbb3..46c1c8ae 100644 --- a/lualib/skynet/inject.lua +++ b/lualib/skynet/inject.lua @@ -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 diff --git a/service/debug_console.lua b/service/debug_console.lua index b34067ff..7029c802 100644 --- a/service/debug_console.lua +++ b/service/debug_console.lua @@ -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)