Catch exception when word contains invalid data#6325
Merged
Conversation
An example document contained some kind of hidden hyperlink, which looks like it is an invalid element. When trying to get range information an exception is thrown with the COM error "Object has been deleted". The fix is to catch the exception, record information in the log, and discard the item, continuing with iteration over the rest of the items.
Contributor
Author
|
@michaelDCurran Could you please take a look at this when you get the chance? |
| try: | ||
| item=self.quickNavItemClass(self.itemType,self.document,collectionItem) | ||
| itemRange=item.rangeObj | ||
| except: |
Member
There was a problem hiding this comment.
I assume it raises COMError? If so perhaps best to just catch that specifically, so as to not hide other more critical errors.
Member
|
Fine with it, barring the except statement. |
| itemRange=item.rangeObj | ||
| try: | ||
| item=self.quickNavItemClass(self.itemType,self.document,collectionItem) | ||
| itemRange=item.rangeObj |
Contributor
There was a problem hiding this comment.
Please move this outside the try/except.
Contributor
|
All good! |
feerrenrut
added a commit
that referenced
this pull request
Sep 5, 2016
feerrenrut
added a commit
that referenced
this pull request
Sep 19, 2016
Fixed an issue that stops the the elements list from appearing when Microsoft Word contains an invalid hyperlink. (#5886)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An example document contained some kind of hidden hyperlink, which looks
like it is an invalid element. When trying to get range information an
exception is thrown with the COM error "Object has been deleted". The
fix is to catch the exception, record information in the log, and
discard the item, continuing with iteration over the rest of the items.
Fixes #5886