diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-18 10:51:56 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-18 10:51:56 +0000 |
| commit | 0459e2cf53ad8670e6692020f5864eafffe2caf9 (patch) | |
| tree | 696066f4fe3b9f66abcc29386d9be73ac0c31c5d /lib | |
| parent | 7194953e90ab7a24b49f471b23cc30d03beba517 (diff) | |
Improve error message when failing to find the body element in a document
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/document-xml-reader.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/docx/document-xml-reader.js b/lib/docx/document-xml-reader.js index c5472c2..9543ed8 100644 --- a/lib/docx/document-xml-reader.js +++ b/lib/docx/document-xml-reader.js @@ -10,6 +10,10 @@ function DocumentXmlReader(options) { function convertXmlToDocument(element) { var body = element.first("w:body"); + if (body == null) { + throw new Error("Could not find the body element: are you sure this is a docx file?"); + } + var result = bodyReader.readXmlElements(body.children) .map(function(children) { return new documents.Document(children, { |
