aoxu
8/2/2013 - 11:54 AM

改进后的luaCaller

改进后的luaCaller

function luaErrHandler(err)
    print("lua error", err)
    print(debug.traceback())
    os.exit() -- force exit
end

function luaCaller(module, func, params)   
    if(params=="") then
        tableParams ={}
    else
        tableParams = json.decode(params)
    end
    luaFunc =loadstring("return " .. module .. "." .. func .. "(tableParams)");
    isSuccess, result = xpcall(luaFunc, luaErrHandler)
    return json.encode(result)
end