From: Tobias Ulmer Date: Thu, 25 Apr 2013 14:12:41 +0000 (+0200) Subject: Add error handling to e2lib.init2() X-Git-Tag: e2factory-2.3.15rc1~516 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=78ed77a3ae874b09e47f43ffb7d5c90185cab0b7;p=e2factory.git Add error handling to e2lib.init2() Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 5342d86..2183326 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -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 diff --git a/global/e2-create-project.lua b/global/e2-create-project.lua index 04db30d..14523f5 100644 --- a/global/e2-create-project.lua +++ b/global/e2-create-project.lua @@ -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() diff --git a/global/e2-fetch-project.lua b/global/e2-fetch-project.lua index c5e97a3..64c64e6 100644 --- a/global/e2-fetch-project.lua +++ b/global/e2-fetch-project.lua @@ -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() diff --git a/global/e2-install-e2.lua b/global/e2-install-e2.lua index 4e13f69..a648d03 100644 --- a/global/e2-install-e2.lua +++ b/global/e2-install-e2.lua @@ -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() diff --git a/local/e2tool.lua b/local/e2tool.lua index a5348d5..47cdfb2 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -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