Skip to content

Commit

Permalink
Fix issue #121 by making sure the last captured exception is thrown a…
Browse files Browse the repository at this point in the history
…fter we run out of schemes
  • Loading branch information
ndw committed Sep 21, 2013
1 parent 1368482 commit 47ab9c9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/com/xmlcalabash/util/XPointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,21 @@ public Vector<XdmNode> selectNodes(XProcRuntime runtime, XdmNode doc) {

public String selectText(InputStreamReader stream, int contentLength) {
String result = null;
RuntimeException except = null;

for (XPointerScheme scheme : parts) {
String select = scheme.textEquivalent();
if (result == null && select != null) {
try {
result = scheme.selectText(stream, contentLength);
} catch (IllegalArgumentException iae) {
result = null;
// in this case we will never have started reading the file, so we're good to go
} catch (XProcException xe) {
except = iae;
result = null;
} catch (XProcException xe) {
// try the next one
except = xe;
result = null;
try {
stream.reset();
} catch (IOException ioe) {
Expand All @@ -87,6 +90,10 @@ public String selectText(InputStreamReader stream, int contentLength) {
}
}

if (result == null && except != null) {
throw except;
}

return result;
}

Expand Down

0 comments on commit 47ab9c9

Please sign in to comment.