cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r794093 - /cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/StatusCodeCollector.java
Date Tue, 14 Jul 2009 22:15:54 GMT
Author: reinhard
Date: Tue Jul 14 22:15:54 2009
New Revision: 794093

URL: http://svn.apache.org/viewvc?rev=794093&view=rev
Log:
improve error message if the status-code is a non-numeric value

Modified:
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/StatusCodeCollector.java

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/StatusCodeCollector.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/StatusCodeCollector.java?rev=794093&r1=794092&r2=794093&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/StatusCodeCollector.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/StatusCodeCollector.java
Tue Jul 14 22:15:54 2009
@@ -31,12 +31,14 @@
 import org.aspectj.lang.annotation.Aspect;
 
 /**
- * This {@link Aspect} is used to collect the status-code property from a {@link SerializeNode}
because the sitemap
- * interpreter doesn't have any dependencies on the Servlet API and doesn't 'know' about
the concepts of HTTP.
+ * This {@link Aspect} is used to collect the status-code property from a {@link SerializeNode}
+ * because the sitemap interpreter doesn't have any dependencies on the Servlet API and doesn't
+ * 'know' about the concepts of HTTP.
  *
- * A servlet that uses the the {@link Sitemap} (e.g. the {@link XMLSitemapServlet}) can use
this collector to read the
- * status code and set it on the servlet response object. The collector can also be used
to directly manipulate the
- * status code of the current thread by using the {@link #setStatusCode(int)} method.
+ * A servlet that uses the the {@link Sitemap} (e.g. the {@link XMLSitemapServlet}) can use
this
+ * collector to read the status code and set it on the servlet response object. The collector
can
+ * also be used to directly manipulate the status code of the current thread by using the
+ * {@link #setStatusCode(int)} method.
  */
 @Aspect
 public class StatusCodeCollector {
@@ -65,9 +67,22 @@
         InvocationResult invocationResult = (InvocationResult) proceedingJoinPoint.proceed();
 
         if (invocationResult.isContinued() && statusCode != null) {
-            setStatusCode(Integer.valueOf(statusCode));
+            try {
+                setStatusCode(Integer.valueOf(statusCode));
+            } catch (NumberFormatException nfe) {
+                throw new InvalidStatusCodeException("The status-code '" + statusCode + "
is not valid number.", nfe);
+            }
         }
 
         return invocationResult;
     }
+
+    private static class InvalidStatusCodeException extends RuntimeException {
+
+        private static final long serialVersionUID = 1L;
+
+        public InvalidStatusCodeException(String message, Throwable t) {
+            super(message, t);
+        }
+    }
 }



Mime
View raw message