You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2007/12/12 20:52:19 UTC
svn commit: r603715 - in /tiles/framework/trunk:
tiles-core/src/main/java/org/apache/tiles/portlet/context/
tiles-core/src/main/java/org/apache/tiles/servlet/context/
tiles-jsp/src/main/java/org/apache/tiles/jsp/context/
Author: apetrelli
Date: Wed Dec 12 11:52:18 2007
New Revision: 603715
URL: http://svn.apache.org/viewvc?rev=603715&view=rev
Log:
TILES-230
Popping up the root causes of ServletExceptions when possible.
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContext.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/context/ServletTilesRequestContext.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContext.java?rev=603715&r1=603714&r2=603715&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContext.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContext.java Wed Dec 12 11:52:18 2007
@@ -239,7 +239,7 @@
(RenderResponse) response);
} catch (PortletException e) {
throw new IOException("PortletException while including path '"
- + path + "'." + e.getMessage());
+ + path + "'.", e);
}
}
}
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/context/ServletTilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/context/ServletTilesRequestContext.java?rev=603715&r1=603714&r2=603715&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/context/ServletTilesRequestContext.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/context/ServletTilesRequestContext.java Wed Dec 12 11:52:18 2007
@@ -30,23 +30,16 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.tiles.context.TilesRequestContext;
/**
- * Servlet-bsed implementation of the TilesApplicationContext interface.
+ * Servlet-based implementation of the TilesApplicationContext interface.
*
* @version $Rev$ $Date$
*/
public class ServletTilesRequestContext extends ServletTilesApplicationContext implements TilesRequestContext {
/**
- * The logging object.
- */
- private static final Log LOG = LogFactory.getLog(ServletTilesRequestContext.class);
-
- /**
* The request object to use.
*/
private HttpServletRequest request;
@@ -197,9 +190,7 @@
try {
rd.forward(request, response);
} catch (ServletException ex) {
- LOG.error("Servlet Exception while including path", ex);
- throw new IOException("Error including path '" + path + "'. "
- + ex.getMessage());
+ throw wrapServletException(ex, path);
}
}
@@ -211,9 +202,7 @@
try {
rd.include(request, response);
} catch (ServletException ex) {
- LOG.error("Servlet Exception while including path", ex);
- throw new IOException("Error including path '" + path + "'. "
- + ex.getMessage());
+ throw wrapServletException(ex, path);
}
}
@@ -275,5 +264,28 @@
/** {@inheritDoc} */
public boolean isUserInRole(String role) {
return request.isUserInRole(role);
+ }
+
+ /**
+ * Wraps a ServletException to create an IOException with the root cause if present.
+ *
+ * @param ex The exception to wrap.
+ * @param path The path that failed.
+ * @return The wrapped exception.
+ */
+ protected IOException wrapServletException(ServletException ex, String path) {
+ IOException retValue;
+ Throwable rootCause = ex.getRootCause();
+ if (rootCause != null) {
+ // Replace the ServletException with an IOException, with the root
+ // cause of the first as the cause of the latter.
+ retValue = new IOException("JSPException while including path '"
+ + path + "'.", rootCause);
+ } else {
+ retValue = new IOException("JSPException while including path '"
+ + path + "'.", ex);
+ }
+
+ return retValue;
}
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java?rev=603715&r1=603714&r2=603715&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java Wed Dec 12 11:52:18 2007
@@ -20,8 +20,6 @@
*/
package org.apache.tiles.jsp.context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.servlet.context.ServletTilesRequestContext;
@@ -42,13 +40,6 @@
implements TilesRequestContext {
/**
- * The logging object.
- */
- private static final Log LOG =
- LogFactory.getLog(JspTilesRequestContext.class);
-
-
- /**
* The current page context.
*/
private PageContext pageContext;
@@ -88,9 +79,7 @@
try {
pageContext.include(path, false);
} catch (ServletException e) {
- LOG.error("ServletException while including path '" + path + "'. ", e);
- throw new IOException("JSPException while including path '" + path
- + "'. " + e.getMessage());
+ throw wrapServletException(e, path);
}
}