From 1c0b9859061de48b3246a6b274cb33b506217e53 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 21 Mar 2016 02:18:01 -0400 Subject: pandoc.rb: better error handling --- pandoc.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3