sylvain 01/10/17 03:06:25
Modified: . changes.xml
src/org/apache/cocoon Notification.java
src/org/apache/cocoon/components/language/generator
GeneratorSelector.java
src/org/apache/cocoon/components/language/markup/sitemap/java
sitemap.xsl
src/org/apache/cocoon/sitemap Handler.java Manager.java
Log:
Reduce exception nesting in case of sitemap setup errors, and display all
nested exceptions in the error page (avoids searching the logs for the failure
cause)
Revision Changes Path
1.41 +12 -1 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- changes.xml 2001/10/16 13:45:17 1.40
+++ changes.xml 2001/10/17 10:06:24 1.41
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.40 2001/10/16 13:45:17 cziegeler Exp $
+ $Id: changes.xml,v 1.41 2001/10/17 10:06:24 sylvain Exp $
-->
<changes title="History of Changes">
@@ -26,6 +26,17 @@
</devs>
<release version="2.1-dev" date="@date@">
+ <action dev="SW" type="fix">
+ Reduce exception nesting in case of sitemap setup errors, and display
all nested exceptions
+ in the error page (avoids searching the logs for the failure cause).
+ </action>
+ <action dev="SW" type="update">
+ Added attribute management methods to environment Context and its
implementations.
+ </action>
+ <action dev="SW" type="update">
+ Updated TraxTransformer and XSLTProcessor to allow simultaneous use of
several
+ TRAX processors (e.g. xalan and saxon) in a controlled way.
+ </action>
<action dev="CZ" type="update">
Added support for configurable SourceFactories.
Patch submitted by Gianugo Rabellino [EMAIL PROTECTED]
1.7 +38 -4 xml-cocoon2/src/org/apache/cocoon/Notification.java
Index: Notification.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Notification.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Notification.java 2001/10/11 07:28:15 1.6
+++ Notification.java 2001/10/17 10:06:24 1.7
@@ -106,15 +106,25 @@
} else {
stackTraceException = t;
}
- StringWriter stackTrace = new StringWriter();
- stackTraceException.printStackTrace(new PrintWriter(stackTrace));
- extraDescriptions.put("stacktrace", stackTrace.toString());
+ StringWriter sw = new StringWriter();
+ stackTraceException.printStackTrace(new PrintWriter(sw));
+ extraDescriptions.put("stacktrace", sw.toString());
+ // Add nested throwables description
+ sw = new StringWriter();
+ appendCauses(new PrintWriter(sw), stackTraceException);
+
+ String causes = sw.toString();
+ if (causes != null && causes.length() != 0) {
+ extraDescriptions.put("original exception", causes);
+ }
+
+/* Now handled by appendCauses()
// if the throwable is a CascadingThrowable the strack trace
// is automatically appended by the CascadingThrowable, so we
// only have to deal with the case if the embedded exception
// of the CascadingThrowable is a SAXException.
- if (t instanceof CascadingThrowable) {
+ if (t instanceof CascadingThrowable) {
Throwable cause = ((CascadingThrowable)t).getCause();
if(cause != null && cause instanceof SAXException) {
cause = ((SAXException)cause).getException();
@@ -126,6 +136,30 @@
}
}
}
+*/
+ }
+ }
+
+ /**
+ * Print recursively all nested causes of a Throwable in a PrintWriter.
+ */
+ public void appendCauses(PrintWriter out, Throwable t) {
+ Throwable cause = null;
+ if (t instanceof CascadingThrowable) {
+ cause = ((CascadingThrowable)t).getCause();
+ } else if (t instanceof SAXException) {
+ cause = ((SAXException)t).getException();
+ } else if (t instanceof java.sql.SQLException) {
+ cause = ((java.sql.SQLException)t).getNextException();
+ }
+
+ if (cause != null) {
+ out.print("Original exception : ");
+ cause.printStackTrace(out);
+ out.println();
+
+ // Recurse
+ appendCauses(out, cause);
}
}
1.12 +6 -12
xml-cocoon2/src/org/apache/cocoon/components/language/generator/GeneratorSelector.java
Index: GeneratorSelector.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/generator/GeneratorSelector.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- GeneratorSelector.java 2001/10/11 07:20:25 1.11
+++ GeneratorSelector.java 2001/10/17 10:06:24 1.12
@@ -28,7 +28,7 @@
* includes Sitemaps and XSP Pages
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.11 $ $Date: 2001/10/11 07:20:25 $
+ * @version CVS $Revision: 1.12 $ $Date: 2001/10/17 10:06:24 $
*/
public class GeneratorSelector extends ExcaliburComponentSelector implements
Disposable {
@@ -112,19 +112,15 @@
}
}
- private void addGenerator(Object hint) throws ComponentException {
+ private void addGenerator(Object hint) throws Exception {
Class generator;
String className = hint.toString().replace(File.separatorChar, '.');
- try {
- generator = this.classManager.loadClass(className);
- } catch (Exception e) {
- throw new ComponentException("Could not add component for class:
" + className, e);
- }
+ generator = this.classManager.loadClass(className);
this.addGenerator(this.manager, hint, generator);
}
- protected void addGenerator(ComponentManager newManager, Object hint,
Class generator) throws ComponentException {
+ protected void addGenerator(ComponentManager newManager, Object hint,
Class generator) throws Exception {
try
{
final ComponentHandler handler =
@@ -142,10 +138,8 @@
}
catch( final Exception e )
{
- final String message =
- "Could not set up Component for hint: " + hint;
- getLogger().error( message, e);
- throw new ComponentException( message, e );
+ getLogger().error("Could not set up Component for hint: " +
hint, e);
+ throw e;
}
}
1.43 +2 -2
xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- sitemap.xsl 2001/10/12 09:32:32 1.42
+++ sitemap.xsl 2001/10/17 10:06:24 1.43
@@ -124,7 +124,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo
Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin
Loritsch</a>
- * @version CVS $Id: sitemap.xsl,v 1.42 2001/10/12 09:32:32 cziegeler
Exp $
+ * @version CVS $Id: sitemap.xsl,v 1.43 2001/10/17 10:06:24 sylvain Exp $
*/
public class <xsl:value-of select="@file-name"/> extends AbstractSitemap
{
static final String LOCATION = "<xsl:value-of
select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
@@ -259,7 +259,7 @@
/* catch any exception thrown by a component during configuration */
} catch (Exception e) {
getLogger().warn(e.getMessage(), e);
- throw new ConfigurationException ("Sitemap: " + e.getMessage(), e);
+ throw new ConfigurationException ("Error in sitemap configuration
: " + e.getMessage(), e);
}
}
1.22 +2 -5 xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java
Index: Handler.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Handler.java 2001/10/11 07:28:23 1.21
+++ Handler.java 2001/10/17 10:06:24 1.22
@@ -41,7 +41,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.21 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.22 $ $Date: 2001/10/17 10:06:24 $
*/
public class Handler extends AbstractLoggable
implements Runnable, Contextualizable, Composable, Processor, Disposable,
SourceResolver {
@@ -238,10 +238,7 @@
public void throwEventualException() throws Exception {
if (this.exception != null) {
- if(this.exception instanceof ProcessingException)
- throw this.exception;
- else
- throw new ProcessingException("Exception in Handler",
this.exception);
+ throw this.exception;
}
}
1.19 +7 -4 xml-cocoon2/src/org/apache/cocoon/sitemap/Manager.java
Index: Manager.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Manager.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Manager.java 2001/10/11 07:28:23 1.18
+++ Manager.java 2001/10/17 10:06:24 1.19
@@ -34,7 +34,7 @@
* checking regeneration of the sub <code>Sitemap</code>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.18 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.19 $ $Date: 2001/10/17 10:06:24 $
*/
public class Manager
extends AbstractLoggable
@@ -238,9 +238,12 @@
private void setupProcessing(Environment environment, Handler
sitemapHandler, String uri_prefix,
String source) throws Exception {
if (!sitemapHandler.available()) {
- throw new ProcessingException("The sitemap handler's sitemap
is not available. " +
- "Please check logs for the exact error.",
- sitemapHandler.getException());
+ if (sitemapHandler.getException() != null) {
+ throw sitemapHandler.getException();
+ } else {
+ throw new ProcessingException("The sitemap handler's
sitemap is not available. " +
+ "Please check logs for the exact error.");
+ }
}
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]