summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-03-21 02:18:01 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-03-21 02:18:01 -0400
commit1c0b9859061de48b3246a6b274cb33b506217e53 (patch)
tree00fa3c1645341dd6df45ac948ba7a369ac330960
parent75081c63ee8b204a239572a232d50455556882f4 (diff)
pandoc.rb: better error handling
-rw-r--r--pandoc.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/pandoc.rb b/pandoc.rb
index a653978..9c12351 100644
--- a/pandoc.rb
+++ b/pandoc.rb
@@ -18,10 +18,15 @@ module Pandoc
str = str.read
end
json = ''
+ errors = ''
Open3::popen3(cmd) do |stdin, stdout, stderr|
stdin.puts(str)
stdin.close
json = stdout.read
+ errors = stderr.read
+ end
+ unless errors.empty?
+ raise errors
end
return Pandoc::AST::new(json)
end
@@ -38,12 +43,17 @@ module Pandoc
def to(format)
cmd = Pandoc::prog + " -f json -t " + format.to_s
output = ''
+ errors = ''
Open3::popen3(cmd) do |stdin, stdout, stderr|
stdin.puts @js.to_json
stdin.close
output = stdout.read
+ errors = stderr.read
+ end
+ unless errors.empty?
+ raise errors
end
- output
+ return output
end
def self.js2sane(js)