Skip to content

Commit 0cea2ff

Browse files
authored
Merge pull request #751 from returnly/raise_on_all_errors
Raise exception on all pdf generation errors
2 parents f06f00e + 6787112 commit 0cea2ff

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class ThingsController < ApplicationController
179179
no_background: true,
180180
viewport_size: 'TEXT', # available only with use_xserver or patched QT
181181
extra: '', # directly inserted into the command to wkhtmltopdf
182+
raise_on_all_errors: nil, # raise error for any stderr output. Such as missing media, image assets
182183
outline: { outline: true,
183184
outline_depth: LEVEL },
184185
margin: { top: SIZE, # default 10 (mm)

lib/wicked_pdf.rb

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def pdf_from_url(url, options = {})
8585
generated_pdf_file.rewind
8686
generated_pdf_file.binmode
8787
pdf = generated_pdf_file.read
88+
raise "Error generating PDF\n Command Error: #{err}" if options[:raise_on_all_errors] && !err.empty?
8889
raise "PDF could not be generated!\n Command Error: #{err}" if pdf && pdf.rstrip.empty?
8990
pdf
9091
rescue StandardError => e

0 commit comments

Comments
 (0)