Skip to content

Commit

Permalink
Manually apply #178, report NPEs more explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
ndw committed Mar 4, 2018
1 parent b72e2f3 commit f19da5c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/xmlcalabash/extensions/Zip.java
Expand Up @@ -143,6 +143,9 @@ public void run() throws SaxonApiException {
final String zipFn = getOption(_href).getString();

XdmNode man = S9apiUtils.getDocumentElement(manifest.read());
if (man == null) {
throw new NullPointerException("XML document " + man.getDocumentURI() + " has no root element.");
}

if (!c_zip_manifest.equals(man.getNodeName())) {
throw new XProcException(step.getNode(), "The cx:zip manifest must be a c:zip-manifest.");
Expand All @@ -151,6 +154,9 @@ public void run() throws SaxonApiException {
while (source.moreDocuments()) {
XdmNode doc = source.read();
XdmNode root = S9apiUtils.getDocumentElement(doc);
if (root == null) {
throw new NullPointerException("XML document " + doc.getDocumentURI() + " has no root element.");
}
srcManifest.put(root.getBaseURI().toASCIIString(), doc);
}

Expand Down

0 comments on commit f19da5c

Please sign in to comment.