diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-18 10:59:28 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-18 10:59:28 +0000 |
| commit | c210c304a329de3184a04448fa11b31bc5933193 (patch) | |
| tree | 181e8c080a3d19791c8fbc2a26d1cd20542237a7 /mammoth/docx/document_xml.py | |
| parent | 0204b943b1a4daaf102ec53b59cd491d9dc3984f (diff) | |
Improve error message when failing to find the body element in a document
Diffstat (limited to 'mammoth/docx/document_xml.py')
| -rw-r--r-- | mammoth/docx/document_xml.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mammoth/docx/document_xml.py b/mammoth/docx/document_xml.py index e0d19a4..45905c6 100644 --- a/mammoth/docx/document_xml.py +++ b/mammoth/docx/document_xml.py @@ -6,13 +6,17 @@ def read_document_xml_element( body_reader, notes=None, comments=None): - + if notes is None: notes = [] if comments is None: comments = [] - + body_element = element.find_child("w:body") + + if body_element is None: + raise ValueError("Could not find the body element: are you sure this is a docx file?") + return body_reader.read_all(body_element.children) \ .map(lambda children: documents.document( children, |
