]> git.e2factory.org Git - e2factory.git/commitdiff
Add error handling to e2lib.init2()
authorTobias Ulmer <tu@emlix.com>
Thu, 25 Apr 2013 14:12:41 +0000 (16:12 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 13:58:55 +0000 (14:58 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua
global/e2-create-project.lua
global/e2-fetch-project.lua
global/e2-install-e2.lua
local/e2tool.lua

index 5342d8670a0e4ace5aa9bc2ee3b142c176370460..2183326a53704a53a411e82dcb622b8f360a065b 100644 (file)
@@ -232,6 +232,8 @@ function e2lib.init()
 end
 
 --- init2.
+-- @return True on success, false on error.
+-- @return Error object on failure.
 function e2lib.init2()
     local rc, re
     local e = err.new("initializing globals (step2)")
@@ -257,14 +259,16 @@ function e2lib.init2()
     -- initialize the tools library after resetting tools
     local rc, re = tools.init()
     if not rc then
-        e2lib.abort(e:cat(re))
+        return false, e:cat(re)
     end
 
     -- get host system architecture
     local host_system_arch, re = e2lib.get_sys_arch()
     if not host_system_arch then
-        e2lib.abort(e:cat(re))
+        return false, e:cat(re)
     end
+
+    return true
 end
 
 --- function call tracer
index 04db30d53204c1a62100413bdca7bdb6c0a3c03b..14523f5bef0e9ef632b0ebfd0e2c392226be937b 100644 (file)
@@ -50,7 +50,12 @@ local function e2_create_project(arg)
     if not rc then
         return false, e
     end
-    e2lib.init2()
+
+    rc, re = e2lib.init2()
+    if not rc then
+        return false, re
+    end
+
     local e = err.new("creating project failed")
 
     local config, re = e2lib.get_global_config()
index c5e97a30d6190e00396b6eb62f13c3029758a495..64c64e66d2be690301a4a71f5dd6f1659ef27758 100644 (file)
@@ -50,11 +50,15 @@ local function e2_fetch_project(arg)
         return false, arguments
     end
 
-    local rc, re = e2lib.read_global_config()
+    rc, re = e2lib.read_global_config()
     if not rc then
         return false, e:cat(re)
     end
-    e2lib.init2()
+
+    rc, re = e2lib.init2()
+    if not rc then
+        return false, re
+    end
 
     -- get the global configuration
     local config = e2lib.get_global_config()
index 4e13f6947017a3af5279069c4ffae02bc21e7038..a648d03f1c61a1a86d7663fe5a25ab06f324683d 100644 (file)
@@ -59,7 +59,12 @@ local function e2_install_e2(arg)
     if not rc then
         return false, e
     end
-    e2lib.init2()
+
+    rc, re = e2lib.init2()
+    if not rc then
+        return false, re
+    end
+
     local e = err.new("e2-install-e2 failed")
 
     local config = e2lib.get_global_config()
index a5348d5b0fb119aa9bbae910789577cfc4169fae..47cdfb233189f4052ad2097f54949c584f6aa7f1 100644 (file)
@@ -1175,7 +1175,10 @@ function e2tool.collect_project_info(info, skip_load_config)
 
     info.local_template_path = e2lib.join(info.root, "/.e2/lib/e2/templates")
 
-    e2lib.init2() -- configuration must be available
+    rc, re = e2lib.init2() -- configuration must be available
+    if not rc then
+        return false, re
+    end
 
     if skip_load_config == true then
         return info