Skip to content

Commit

Permalink
Also fetch stderr, so that the generation error can be reported in th…
Browse files Browse the repository at this point in the history
…e exception.
  • Loading branch information
tiennou committed Sep 2, 2010
1 parent 49d9f79 commit eb844e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/wicked_pdf.rb
Expand Up @@ -24,16 +24,16 @@ def initialize(wkhtmltopdf_binary_path = nil)
def pdf_from_string(string, options={})
command_for_stdin_stdout = "#{@exe_path} #{parse_options(options)} -q - - " # -q for no errors on stdout
p "*"*15 + command_for_stdin_stdout + "*"*15 unless defined?(Rails) and Rails.env != 'development'
pdf = begin
pdf, err = begin
Open3.popen3(command_for_stdin_stdout) do |stdin, stdout, stderr|
stdin.write(string)
stdin.close
stdout.read
[stdout.read, stderr.read]
end
rescue Exception => e
raise "Failed to execute #{@exe_path}: #{e}"
end
raise "PDF could not be generated!\n#{stderr.read}" if pdf and pdf.length == 0
raise "PDF could not be generated!\n#{err}" if pdf and pdf.length == 0
pdf
end

Expand Down

0 comments on commit eb844e7

Please sign in to comment.