From e38a055f8dd076cc8cc3db4d56f1171d274e36b9 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 15 Apr 2013 20:22:26 +0200 Subject: refactored error handling, less error prone --- src/luarocks/build/builtin.lua | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 3d179b34..9d97d58b 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -217,8 +217,7 @@ function run(rockspec) end ok = compile_object(object, source, info.defines, info.incdirs) if not ok then - err = "Failed compiling object "..object - break + return nil, "Failed compiling object "..object end table.insert(objects, object) end @@ -231,30 +230,22 @@ function run(rockspec) built_modules[module_name] = dest ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) if not ok then - err = "Failed compiling module "..module_name - break + return nil, "Failed compiling module "..module_name end end end - if ok then - for name, dest in pairs(built_modules) do - fs.make_dir(dest) - ok = fs.copy(name, dest) - if not ok then - err = "Failed installing "..name.." in "..dest - break - end + for name, dest in pairs(built_modules) do + fs.make_dir(dest) + ok = fs.copy(name, dest) + if not ok then + return nil, "Failed installing "..name.." in "..dest end end - if ok then - if fs.is_dir("lua") then - ok, err = fs.copy_contents("lua", luadir) - if not ok then err = "Failed copying contents of 'lua' directory: "..err end + if fs.is_dir("lua") then + ok, err = fs.copy_contents("lua", luadir) + if not ok then + return nil, "Failed copying contents of 'lua' directory: "..err end end - if ok then - return true - else - return nil, err - end + return true end -- cgit v1.2.3-55-g6feb