You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by wg...@apache.org on 2006/10/11 00:17:38 UTC

svn commit: r462604 - in /jakarta/velocity/engine/trunk/src/java/org/apache/velocity: app/ exception/ runtime/directive/ runtime/exception/ runtime/parser/ runtime/parser/node/ util/introspection/

Author: wglass
Date: Tue Oct 10 15:17:37 2006
New Revision: 462604

URL: http://svn.apache.org/viewvc?view=rev&rev=462604
Log:
Bold commit moving application-level exceptions to be based on RuntimeException.

Modified:
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/exception/VelocityException.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/exception/ReferenceException.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParseException.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
    jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/app/Velocity.java Tue Oct 10 15:17:37 2006
@@ -372,35 +372,33 @@
 
         try
         {
-            boolean retval = evaluate(  context,  writer,
+            return evaluate(  context,  writer,
                                          logTag, construct.toString() );
-
-            return retval;
-        }
-        /**
-         * pass through application level runtime exceptions
-         */
-        catch(RuntimeException re)
-        {
-            throw re;
         }
+
         catch(ParseErrorException pee)
         {
-            getLog().error("Velocity.invokeVelocimacro() failed", pee);
+            throw pee;
         }
         catch(MethodInvocationException mie)
         {
-            getLog().error("Velocity.invokeVelocimacro() failed", mie);
+            throw mie;
         }
         catch(ResourceNotFoundException rnfe)
         {
-            getLog().error("Velocity.invokeVelocimacro() failed", rnfe);
+            throw rnfe;
         }
         catch(IOException ioe)
         {
             getLog().error("Velocity.invokeVelocimacro() failed", ioe);
         }
-
+        /**
+         * pass through application level runtime exceptions
+         */
+        catch(RuntimeException re)
+        {
+            throw re;
+        }
         return false;
     }
 

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/exception/VelocityException.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/exception/VelocityException.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/exception/VelocityException.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/exception/VelocityException.java Tue Oct 10 15:17:37 2006
@@ -17,13 +17,13 @@
  */
 
 /**
- *  Base class for Velocity exceptions thrown to the
- *  application layer.
+*  Base class for Velocity runtime exceptions thrown to the 
+ * application layer.    
  *
  * @author <a href="mailto:kdowney@amberarcher.com">Kyle F. Downey</a>
  * @version $Id$
  */
-public class VelocityException extends Exception
+public class VelocityException extends RuntimeException
 {
     /**
      * Version Id for serializable

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Parse.java Tue Oct 10 15:17:37 2006
@@ -221,21 +221,24 @@
                 ((SimpleNode) t.getData()).render( context, writer );
             }
         }
-        /**
-         * pass through application level runtime exceptions
+        
+        /*
+         *  if it's a MIE, it came from the render.... throw it...
          */
-        catch( RuntimeException e )
+        catch( MethodInvocationException e )
         {
             throw e;
         }
-
-        /*
-         *  if it's a MIE, it came from the render.... throw it...
+        
+        /**
+         * pass through application level runtime exceptions
          */
-        catch( MethodInvocationException e )
+        catch( RuntimeException e )
         {
             throw e;
         }
+
+
         catch ( Exception e )
         {
             rsvc.getLog().error("Exception rendering #parse(" + arg + ')', e);

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java Tue Oct 10 15:17:37 2006
@@ -190,18 +190,19 @@
                 rsvc.getLog().error("VM error " + macroName + ". Null AST");
             }
         }
-        /**
-         * pass through application level runtime exceptions
+
+        /*
+         *  if it's a MIE, it came from the render.... throw it...
          */
-        catch( RuntimeException e )
+        catch( MethodInvocationException e )
         {
             throw e;
         }
 
-        /*
-         *  if it's a MIE, it came from the render.... throw it...
+        /**
+         * pass through application level runtime exceptions
          */
-        catch( MethodInvocationException e )
+        catch( RuntimeException e )
         {
             throw e;
         }

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/exception/ReferenceException.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/exception/ReferenceException.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/exception/ReferenceException.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/exception/ReferenceException.java Tue Oct 10 15:17:37 2006
@@ -19,7 +19,8 @@
 import org.apache.velocity.runtime.parser.node.Node;
 
 /**
- * Exception thrown when a bad reference is found.
+ * Exception thrown when a bad reference is found.  Typically
+ * caught and logged.
  *
  * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  * @version $Id$

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParseException.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParseException.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParseException.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/ParseException.java Tue Oct 10 15:17:37 2006
@@ -3,7 +3,10 @@
 
 /**
  * This exception is thrown when parse errors are encountered.
- * You can explicitly create objects of this exception type by
+ * It is intended to be caught and typically will be rethrown
+ * as a ParseErrorException.
+ * 
+ * <p>You can explicitly create objects of this exception type by
  * calling the method generateParseException in the generated
  * parser.
  *

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java Tue Oct 10 15:17:37 2006
@@ -210,13 +210,11 @@
                     return ret;
                 }
             }
+
             /**
-             * pass through application level runtime exceptions
+             * For interpolated Strings we do not pass exceptions 
+             * through -- just log the problem and move on.
              */
-            catch( RuntimeException e )
-            {
-                throw e;
-            }
             catch( ParseErrorException  e )
             {
                 log.error("Error in interpolating string literal", e);
@@ -229,6 +227,15 @@
             {
                 log.error("Error in interpolating string literal", e);
             }
+            
+            /**
+             * pass through application level runtime exceptions
+             */
+            catch( RuntimeException e )
+            {
+                throw e;
+            }
+            
             catch( IOException  e )
             {
                 log.error("Error in interpolating string literal", e);

Modified: jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java
URL: http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java?view=diff&rev=462604&r1=462603&r2=462604
==============================================================================
--- jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java (original)
+++ jakarta/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java Tue Oct 10 15:17:37 2006
@@ -133,8 +133,9 @@
     }
 
     /**
-     *  simple distinguishable exception, used when
-     *  we run across ambiguous overloading
+     *  Simple distinguishable exception, used when
+     *  we run across ambiguous overloading.  Caught
+     *  by the introspector.
      */
     public static class AmbiguousException extends Exception
     {



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org