aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/document-xml-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-02-18 10:51:56 +0000
committerMichael Williamson <mike@zwobble.org>2024-02-18 10:51:56 +0000
commit0459e2cf53ad8670e6692020f5864eafffe2caf9 (patch)
tree696066f4fe3b9f66abcc29386d9be73ac0c31c5d /lib/docx/document-xml-reader.js
parent7194953e90ab7a24b49f471b23cc30d03beba517 (diff)
Improve error message when failing to find the body element in a document
Diffstat (limited to 'lib/docx/document-xml-reader.js')
-rw-r--r--lib/docx/document-xml-reader.js4
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, {