Author: markt
Date: Thu Nov  7 12:55:32 2013
New Revision: 1539619

URL: http://svn.apache.org/r1539619
Log:
More useful error message

Modified:
    tomcat/trunk/java/org/apache/catalina/webresources/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java

Modified: 
tomcat/trunk/java/org/apache/catalina/webresources/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/LocalStrings.properties?rev=1539619&r1=1539618&r2=1539619&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/LocalStrings.properties 
Thu Nov  7 12:55:32 2013
@@ -33,6 +33,7 @@ standardRoot.checkStateNotStarted=The re
 standardRoot.createInvalidFile=Unable to create WebResourceSet from [{0}]
 standardRoot.createNoFileResourceSet=The FileResourceSet feature has not yet 
been implemented
 standardRoot.createUnknownType=Unable to create WebResourceSet of unknown type 
[{0}]
+standardRoot.invalidPath=The resource path [{0}] is not valid
 standardRoot.lockedFile=The web application [{0}] failed to close the file 
[{1}] opened via the following stack trace
 standardRoot.noContext=A Context has not been configured for this 
WebResourceRoot
 standardRoot.startInvalidMain=The main resource set specified [{0}] is not 
valid

Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1539619&r1=1539618&r2=1539619&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Thu 
Nov  7 12:55:32 2013
@@ -198,22 +198,25 @@ public class StandardRoot extends Lifecy
 
     @Override
     public WebResource getClassLoaderResource(String path) {
-        if (path == null || path.length() == 0 || !path.startsWith("/")) {
-            throw new IllegalArgumentException();
-        }
+        checkPath(path);
         return getResource("/WEB-INF/classes" + path, true, true);
     }
 
 
     @Override
     public WebResource[] getClassLoaderResources(String path) {
-        if (path == null || path.length() == 0 || !path.startsWith("/")) {
-            throw new IllegalArgumentException();
-        }
+        checkPath(path);
         return getResources("/WEB-INF/classes" + path, true);
     }
 
 
+    private void checkPath(String path) {
+        if (path == null || path.length() == 0 || !path.startsWith("/")) {
+            throw new IllegalArgumentException(
+                    sm.getString("standardRoot.invalidPath", path));
+        }
+    }
+
     protected final WebResource getResourceInternal(String path,
             boolean useClassLoaderResources) {
         WebResource result = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to