Permalink
Browse files

Fix issue #121 by making sure the last captured exception is thrown a…

…fter we run out of schemes
  • Loading branch information...
ndw committed Sep 21, 2013
1 parent 1368482 commit 47ab9c9ae5d201419cc45e3137eea352fb8a8529
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/com/xmlcalabash/util/XPointer.java
@@ -66,18 +66,21 @@ public XPointer(String xpointer) {
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) {
@@ -87,6 +90,10 @@ public String selectText(InputStreamReader stream, int contentLength) {
}
}
if (result == null && except != null) {
throw except;
}
return result;
}

0 comments on commit 47ab9c9

Please sign in to comment.