You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2006/10/12 14:00:28 UTC

svn commit: r463218 - /incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResource.java

Author: ehillenius
Date: Thu Oct 12 05:00:27 2006
New Revision: 463218

URL: http://svn.apache.org/viewvc?view=rev&rev=463218
Log:
don't throw a common exception (result in a stack trace and error page) for shared resources that are not found, but rather log a warning and abort the request, sending a 404 in case this is a web request

Modified:
    incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResource.java

Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResource.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResource.java?view=diff&rev=463218&r1=463217&r2=463218
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResource.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/PackageResource.java Thu Oct 12 05:00:27 2006
@@ -20,12 +20,17 @@
 
 import java.util.Locale;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import wicket.Application;
+import wicket.RequestCycle;
 import wicket.SharedResources;
 import wicket.WicketRuntimeException;
+import wicket.protocol.http.WebRequestCycle;
+import wicket.protocol.http.servlet.AbortWithWebErrorCodeException;
 import wicket.util.lang.Packages;
 import wicket.util.resource.IResourceStream;
 
@@ -333,8 +338,17 @@
 		// Check that resource was found
 		if (resourceStream == null)
 		{
-			throw new WicketRuntimeException("Unable to find package resource [path = "
-					+ absolutePath + ", style = " + style + ", locale = " + locale + "]");
+			String msg = "Unable to find package resource [path = " + absolutePath + ", style = "
+					+ style + ", locale = " + locale + "]";
+			log.warn(msg);
+			if (RequestCycle.get() instanceof WebRequestCycle)
+			{
+				throw new AbortWithWebErrorCodeException(HttpServletResponse.SC_NOT_FOUND, msg);
+			}
+			else
+			{
+				throw new WicketRuntimeException(msg);
+			}
 		}
 		this.locale = resourceStream.getLocale();
 		return resourceStream;