docx icon indicating copy to clipboard operation
docx copied to clipboard

Only close zip file if set

Open bmulholland opened this issue 4 years ago • 3 comments

When an invalid file is passed in and the Zip library throws an error, @zip is not set. Then the ensure runs and tries to close the zip var, which is nil. This raises a new error that covers up the actual error, making the issue harder to investigate. By only closing the zip file if it was actually opened, the original error is raised for invalid docx files.

bmulholland avatar Aug 10 '21 13:08 bmulholland

This will help with issues like https://github.com/ruby-docx/docx/issues/100

bmulholland avatar Aug 10 '21 13:08 bmulholland

Done and done :)

bmulholland avatar Aug 12 '21 12:08 bmulholland

Thanks @bmulholland, this looks like a good change. I ran into this error when using this library for the first time when I didn't have my path correct. So I think this PR would result in a clearer error message.

panozzaj avatar Mar 25 '22 22:03 panozzaj

@satoryu Would love to get this into the repo so we can stop maintaining our custom fork. If I resolve the conflicts now, would you merge it?

bmulholland avatar Sep 07 '23 13:09 bmulholland

@bmulholland yes!

satoryu avatar Sep 07 '23 13:09 satoryu

Oh, well, looks like another, more recent PR was merged that did the same thing...

bmulholland avatar Sep 07 '23 13:09 bmulholland