From 12f8efe0128ade1bd6497a59508f6bd836eb3788 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 5 Oct 2017 11:41:59 +0200 Subject: pandoc.lua: throw better error when pipe command fails A table containing the error code, command, and command output is thrown instead of just a string error message. --- data/pandoc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data') diff --git a/data/pandoc.lua b/data/pandoc.lua index fc83103e0..32e593c22 100644 --- a/data/pandoc.lua +++ b/data/pandoc.lua @@ -792,6 +792,8 @@ end --- Runs command with arguments, passing it some input, and returns the output. -- @treturn string Output of command. +-- @raise A table containing the keys `command`, `error_code`, and `output` is +-- thrown if the command exits with a non-zero error code. -- @usage -- local ec, output = pandoc.pipe("sed", {"-e","s/a/b/"}, "abc") function M.pipe (command, args, input) @@ -806,9 +808,7 @@ function M.pipe (command, args, input) end } ) - -- TODO: drop the wrapping call to `tostring` as soon as hslua supports - -- non-string error objects. - error(tostring(err)) + error(err) end return output end -- cgit v1.2.3