Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix issue #171 by checking for a null input document
  • Loading branch information
ndw committed Aug 21, 2014
1 parent 571e156 commit 475fcd2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/com/xmlcalabash/library/Error.java
Expand Up @@ -65,7 +65,11 @@ public void run() throws SaxonApiException {
super.run();

XdmNode doc = source.read();
finest(null, "Error step " + "???" + " read " + doc.getDocumentURI());
if (doc == null) {
finest(null, "Error step read empty");
} else {
finest(null, "Error step read " + doc.getDocumentURI());
}

RuntimeValue codeNameValue = getOption(_code);
String codeNameStr = codeNameValue.getString();
Expand Down Expand Up @@ -103,13 +107,19 @@ public void run() throws SaxonApiException {
treeWriter.addAttribute(_type, "p:error");
treeWriter.addAttribute(_code, errorCode.toString());
treeWriter.startContent();
treeWriter.addSubtree(doc);
if (doc != null) {
treeWriter.addSubtree(doc);
}
treeWriter.addEndElement();
treeWriter.endDocument();

step.reportError(treeWriter.getResult());

throw new XProcException(errorCode, doc, doc.getStringValue());
if (doc == null) {
throw new XProcException(errorCode);
} else {
throw new XProcException(errorCode, doc, doc.getStringValue());
}
}
}

0 comments on commit 475fcd2

Please sign in to comment.