fagbokforlaget/pdftohtmljs

Correctly create error on binary child process error

pgcalixto opened this issue · 1 comments

Currently, when the child process spawn is closed (child.on('close', ...)), the rejected error is created with custom properties that are not native to Javascript's Error.

This code is at https://github.com/fagbokforlaget/pdftohtmljs/blob/master/lib/pdftohtml.js#L97:

reject(new Error({code: code, msg:`${self.options.bin} returned an error.`, params: self.options.additional}));

Because of this, when pdf2htmlEX returns an error, pdftohtmljs only shows the following message without explicit details about the error:

Error: [object Object]
    at ChildProcess.child.on (/usr/src/app/node_modules/pdftohtmljs/lib/pdftohtml.js:97:18)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

The message above should display explicit details about the error.

@pgcalixto Thanks for PR 👍. Released in pdftohtmljs@0.5.3.