You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/10/13 12:52:17 UTC

svn commit: r824684 - /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java

Author: sebb
Date: Tue Oct 13 10:52:16 2009
New Revision: 824684

URL: http://svn.apache.org/viewvc?rev=824684&view=rev
Log:
Document expected behaviour when Exceptions occur.
Don't exit interactive session on ParseException.

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java?rev=824684&r1=824683&r2=824684&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl/Main.java Tue Oct 13 10:52:16 2009
@@ -22,21 +22,25 @@
 import java.io.InputStreamReader;
 
 import org.apache.commons.jexl.context.HashMapContext;
+import org.apache.commons.jexl.parser.ParseException;
 
 /**
- * Test application for Jexl
- * TODO - needs more options to be more useful.
+ * Test application for JEXL.
+ *
  * @since 2.0
  */
 public class Main {
     /**
-     * Test application for Jexl
+     * Test application for JEXL
      * 
      * If a single argument is present, it is treated as a filename of a JEXL
-     * script to be executed.
+     * script to be executed as a script. Any exceptions terminate the application.
+     * 
      * Otherwise, lines are read from standard input and evaluated.
+     * ParseExceptions and JexlExceptions are logged, and do not cause the application to exit.
+     * This is done so that interactive testing is easier.
      * 
-     * @param args (optional) filename to evaluate. Stored in the args variable.
+     * @param args (optional) filename to execute. Stored in the args variable.
      * 
      * @throws Exception if parsing or IO fail
      */
@@ -57,10 +61,12 @@
                     Expression expression = engine.createExpression(line);
                     Object value = expression.evaluate(context);
                     System.out.println("Return value: " + value);
-                    System.out.print("> ");
+                } catch (ParseException e) {
+                    System.out.println(e.getLocalizedMessage());
                 } catch (JexlException e) {
                     System.out.println(e.getLocalizedMessage());
                 }
+                System.out.print("> ");
             }
         }
     }