]> git.e2factory.org Git - e2factory.git/commitdiff
err: extent cat() to take a format string plus arguments
authorTobias Ulmer <tu@emlix.com>
Mon, 10 Oct 2016 17:27:50 +0000 (19:27 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/err.lua

index 8738b6d8ecb851919942c75cd3e18a686db55afa..afb221b86b95deb62eea6e280a45a2e132c456ed 100644 (file)
@@ -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