Skip to content

Commit

Permalink
fix: Better raise exception when a page fails to parse (#46)
Browse files Browse the repository at this point in the history
* Put safety-checks for failed parse of pages

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

* Bump to docling-parse 1.1.1

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

* Raise from page backend if page is not correctly parsed

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

---------

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
  • Loading branch information
cau-git authored Aug 23, 2024
1 parent 7e84533 commit 8808463
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docling/backend/docling_parse_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def __init__(
self.broken_page = "pages" not in parsed_page
if not self.broken_page:
self._dpage = parsed_page["pages"][0]
else:
raise RuntimeError(
f"Page {page_no} of document {document_hash} could not be parsed."
)

def get_text_in_rect(self, bbox: BoundingBox) -> str:
if self.broken_page:
Expand Down

0 comments on commit 8808463

Please sign in to comment.