harshankur / officeParser

A Node.js library to parse text out of any office file. Currently supports docx, pptx, xlsx and odt, odp, ods..
MIT License
123 stars 17 forks source link

(Bug) Unhandled exceptions in lambda functions cause crashes #22

Closed hvm2hvm closed 9 months ago

hvm2hvm commented 9 months ago

Hi,

I've run into an unhandled exception at line https://github.com/harshankur/officeParser/blob/1ad0832227a490be7bb9b2278ba1572b17dfff38/officeParser.js#L169 (while processing a powerpoint file)

I'm not sure about why it happens but textNode.childNodes[0] is undefined which then fails. The error is not caught since it's part of the lambda function given to map.

The problem is that, since those errors are inside a lambda function, they can't be caught by outside promise .catch'es or try {} catch blocks.

I would make a pull request but since I'm not very familiar with the code, I'm not sure what the right approach would be - it would take a lot of try {} catches to cover all the lambda functions in the file. All the parse functions have a lambda in the .forEach call and a couple in the .filter and .map calls.

If I can help with something to fix this, please let me know, Voicu

hvm2hvm commented 9 months ago

Scratch that, I realise the error cannot be from what I wrote. I'll close this.