From: Tobias Ulmer Date: Mon, 10 Oct 2016 17:27:50 +0000 (+0200) Subject: err: extent cat() to take a format string plus arguments X-Git-Tag: e2factory-2.3.15rc1~71 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=26ac1563d228505462a35a4c418f2bb98bbc0c7b;p=e2factory.git err: extent cat() to take a format string plus arguments Signed-off-by: Tobias Ulmer --- diff --git a/generic/err.lua b/generic/err.lua index 8738b6d..afb221b 100644 --- a/generic/err.lua +++ b/generic/err.lua @@ -54,13 +54,18 @@ end --- insert an error object into another one -- @param e table: the error object -- @param re table: the error object to insert +-- @param ... list of strings required for the format string -- @return table: the error object -function err.cat(e, re) +function err.cat(e, re, ...) assert_err(e) assert(type(re) == "string" or assert_err(re)) -- auto-convert strings to error objects before inserting if type(re) == "string" then - re = err.new("%s", re) + if #{...} > 0 then + re = err.new(re, ...) + else + re = err.new("%s", re) + end end table.insert(e.msg, re) e.count = e.count + 1