Skip to content

Commit

Permalink
Fix: catch unhandled exception in text extractor (#112)
Browse files Browse the repository at this point in the history
* Fix: catch unhandled exception in text extractor
* Fix: return n callback to prevent it being called twice.
  • Loading branch information
Matt Brooks authored and dbashford committed Jan 13, 2017
1 parent 5ee79f0 commit 9d0aacc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/extractors/text.js
Expand Up @@ -10,8 +10,12 @@ function extractText( filePath, options, cb ) {
cb( error, null );
return;
}
encoding = jschardet.detect( data ).encoding.toLowerCase();
decoded = iconv.decode( data, encoding );
try {
encoding = jschardet.detect( data ).encoding.toLowerCase();
decoded = iconv.decode( data, encoding );
} catch ( e ) {
return cb( e );
}
cb( null, decoded );
});
}
Expand Down

0 comments on commit 9d0aacc

Please sign in to comment.