From 26ac1563d228505462a35a4c418f2bb98bbc0c7b Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 10 Oct 2016 19:27:50 +0200 Subject: [PATCH] err: extent cat() to take a format string plus arguments Signed-off-by: Tobias Ulmer --- generic/err.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.39.5