You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2006/07/19 19:31:45 UTC

svn commit: r423537 - /jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/expression/MethodExpression.java

Author: rdonkin
Date: Wed Jul 19 10:31:44 2006
New Revision: 423537

URL: http://svn.apache.org/viewvc?rev=423537&view=rev
Log:
Improved diagnostic logging. Contributed by Holger Haag. JIRA BETWIXT-53.

Modified:
    jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/expression/MethodExpression.java

Modified: jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/expression/MethodExpression.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/expression/MethodExpression.java?rev=423537&r1=423536&r2=423537&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/expression/MethodExpression.java (original)
+++ jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/expression/MethodExpression.java Wed Jul 19 10:31:44 2006
@@ -62,9 +62,10 @@
                 
             } catch (IllegalAccessException e) {
                 // lets try use another method with the same name
+                Method alternate = null;
                 try {
                     Class type = bean.getClass();
-                    Method alternate = findAlternateMethod( type, method );
+                    alternate = findAlternateMethod( type, method );
                     if ( alternate != null ) {
                         try
                         {
@@ -80,10 +81,10 @@
                         return method.invoke( bean, arguments );
                     }
                 } catch (Exception e2) {
-                    handleException(context, e2);
+                    handleException(context, e2, alternate);
                 }
             } catch (Exception e) {
-                handleException(context, e);
+                handleException(context, e, method);
             }
         }
         return null;
@@ -169,10 +170,23 @@
       * @param context the Context being evaluated when the exception occured
       * @param e the exception to handle
       */
-    protected void handleException(Context context, Exception e) {
+    protected void handleException(Context context, Exception e, Method m) {
         // use the context's logger to log the problem
-        context.getLog().error("[MethodExpression] Cannot evaluate expression ", e);
+        context.getLog().error("[MethodExpression] Cannot evaluate method " + m, e);
     }
+    
+    /** 
+     * <p>Log error to context's logger.</p> 
+     *
+     * <p>Allows derived objects to handle exceptions differently.</p>
+     *
+     * @param context the Context being evaluated when the exception occured
+     * @param e the exception to handle
+     */
+   protected void handleException(Context context, Exception e) {
+       // use the context's logger to log the problem
+       context.getLog().error("[MethodExpression] Cannot evaluate method ", e);
+   }
     
     /** 
      * Returns something useful for logging.



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