You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/01/12 08:39:24 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath XPath.java
sboag 01/01/11 23:39:24
Modified: java/src/org/apache/xpath XPath.java
Log:
Modify error handling code in execute method so that exception is
caught and sent to the error listener. There is some danger that
duplicate exceptions could be sent, but that is preferable an exception
not being passed to the error listener at all. Also, make sure the
SourceLocator is set.
Revision Changes Path
1.16 +22 -13 xml-xalan/java/src/org/apache/xpath/XPath.java
Index: XPath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPath.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XPath.java 2001/01/07 06:24:40 1.15
+++ XPath.java 2001/01/12 07:39:24 1.16
@@ -268,27 +268,36 @@
{
xobj = m_mainExp.execute(xctxt);
}
- catch (Exception e)
+ catch (TransformerException te)
{
- if (e instanceof javax.xml.transform.TransformerException)
+ te.setLocator(this.getLocator());
+ ErrorListener el = xctxt.getErrorListener();
+ if(null != el) // defensive, should never happen.
{
- TransformerException te = (TransformerException)e;
- throw new TransformerException(te.getMessage(),
- (SAXSourceLocator)te.getLocator(), e);
+ el.error(te);
}
else
+ throw te;
+ }
+ catch (Exception e)
+ {
+ while (e instanceof org.apache.xml.utils.WrappedRuntimeException)
{
- while (e instanceof org.apache.xml.utils.WrappedRuntimeException)
- {
- e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
- }
+ e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
+ }
- String msg = e.getMessage();
- msg = (msg == null || msg.length()== 0)? "Error in XPath" : msg;
- throw new TransformerException(msg,
- (SAXSourceLocator)getLocator(), e);
+ String msg = e.getMessage();
+ msg = (msg == null || msg.length()== 0)? "Unknown error in XPath" : msg;
+ TransformerException te = new TransformerException(msg,
+ getLocator(), e);
+ ErrorListener el = xctxt.getErrorListener();
+ if(null != el) // defensive, should never happen.
+ {
+ el.error(te);
}
+ else
+ throw te;
}
finally
{