Vadim Gritsenko wrote:
[EMAIL PROTECTED] wrote:
Author: sylvain
Date: Mon Aug 1 09:52:50 2005
New Revision: 226838
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/TraxTransformer.java?rev=226838&r1=226837&r2=226838&view=diff
==============================================================================
---
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/TraxTransformer.java
(original)
+++
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/TraxTransformer.java
Mon Aug 1 09:52:50 2005
@@ -575,7 +610,30 @@
*/
public void endDocument()
throws SAXException {
- super.endDocument();
+ try {
+ super.endDocument();
+ } catch(SAXException se) {
+ // Rethrow
+ throw se;
Nitpicking... Shouldn't this be:
+ } catch(Exception e) {
+ } catch(RuntimeException e) {
+ if (transformerException != null) {
+ // Ignore the fake RuntimeException sent by Xalan
+ Location loc =
ExceptionUtils.getLocation(transformerException);
+ if (loc == null) {
+ // No location: if it's just a wrapper, consider
only the wrapped exception.
+ Throwable realEx = transformerException.getCause();
+ if (realEx == null) realEx = transformerException;
+ + // Now throw an exception
locating the current stylesheet
+ throw new LocatedRuntimeException("Error during
transformation", realEx, new Location(this.inputSource.getURI()));
+ } else {
+ throw new SAXException(transformerException);
+ }
+ } else {
+ // It's not a fake exception
+ throw new SAXException(e);
+ throw e;
It's better to preserve original (non xalan) RuntimeException, than to
wrap it. WDYT?
Hmm... Actually, we should even remove the initial SAXException, i.e.
only having catch(Exception), as any TransformerException that would
have been given to the ErrorListener should prevail on the actual
exception that was caught.
And then yes, once we've unwrapped the exception, we could rethrow
verbatim SAXException and RuntimeException without wrapping them.
Sylvain
--
Sylvain Wallez Anyware Technologies
http://people.apache.org/~sylvain http://www.anyware-tech.com
Apache Software Foundation Member Research & Technology Director