Skip to content

Commit 67e5021

Browse files
authored
SAAS-2669: throw error explicitly using the callback instead of failing due to "Cannot read property 'filename' of undefined" (#1)
1 parent 7e8c02a commit 67e5021

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/pdf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function PDF (html, options) {
4545
PDF.prototype.toBuffer = function PdfToBuffer (callback) {
4646
this.exec(function execPdfToBuffer (err, res) {
4747
if (err) return callback(err)
48+
if (!res) return callback(new Error('html-pdf: PDF generation failed due to an unknown reason'))
4849
fs.readFile(res.filename, function readCallback (err, buffer) {
4950
if (err) return callback(err)
5051
fs.unlink(res.filename, function unlinkPdfFile (err) {

0 commit comments

Comments
 (0)