Created
February 17, 2016 15:39
-
-
Save IanShoe/e92ee20f4862b187f9ae to your computer and use it in GitHub Desktop.
pdf error being eaten
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Parser = require('pdf2json/pdfparser'); | |
var pdfParser = new Parser(); | |
function handler(err, data) { | |
if (err) { | |
console.log('Normal Error Here'); | |
} else if(data) { | |
console.log('We have data, we will now continue with our app'); | |
throw new Error('Something about our app itself blows up and we should see this bubble up'); | |
} | |
} | |
pdfParser.on('pdfParser_dataReady', function(evtData) { | |
if (!!evtData && !!evtData.data) { | |
handler(null, evtData.data); | |
} else { | |
handler('Error parsing file'); | |
} | |
}); | |
pdfParser.on('pdfParser_dataError', function(evtData) { | |
var err = evtData.data; | |
console.log('Error parsing file', err); | |
handler(err); | |
}); | |
pdfParser.loadPDF('path/to/valid/doc.pdf'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment