Author: gbrown
Date: Fri May 21 12:43:07 2010
New Revision: 946987

URL: http://svn.apache.org/viewvc?rev=946987&view=rev
Log:
Add bean type to property exception message (see PIVOT-483).

Modified:
    pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java

Modified: pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java?rev=946987&r1=946986&r2=946987&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java Fri May 21 
12:43:07 2010
@@ -147,6 +147,9 @@ public class BeanAdapter implements Map<
     public static final String SET_PREFIX = "set";
     public static final String FIELD_PREFIX = "~";
 
+    private static final String PROPERTY_EXCEPTION_MESSAGE_FORMAT =
+        "Unable to access property \"%s\" for type %s.";
+
     /**
      * Creates a new bean dictionary that is not associated with a bean.
      */
@@ -214,7 +217,8 @@ public class BeanAdapter implements Map<
                 try {
                     value = field.get(bean);
                 } catch (IllegalAccessException exception) {
-                    throw new RuntimeException("Unable to access property \"" 
+ key + "\".", exception);
+                    throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                        key, bean.getClass().getName()), exception);
                 }
             }
         } else {
@@ -224,9 +228,11 @@ public class BeanAdapter implements Map<
                 try {
                     value = getterMethod.invoke(bean, new Object[] {});
                 } catch (IllegalAccessException exception) {
-                    throw new RuntimeException("Unable to access property \"" 
+ key + "\".", exception);
+                    throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                        key, bean.getClass().getName()), exception);
                 } catch (InvocationTargetException exception) {
-                    throw new RuntimeException("Unable to access property \"" 
+ key + "\".", exception.getCause());
+                    throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                        key, bean.getClass().getName()), exception.getCause());
                 }
             }
         }
@@ -280,7 +286,8 @@ public class BeanAdapter implements Map<
             try {
                 field.set(bean, value);
             } catch (IllegalAccessException exception) {
-                throw new RuntimeException("Unable to access property \"" + 
key + "\".", exception);
+                throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                    key, bean.getClass().getName()), exception);
             }
         } else {
             Method setterMethod = null;
@@ -309,9 +316,11 @@ public class BeanAdapter implements Map<
             try {
                 setterMethod.invoke(bean, new Object[] {value});
             } catch (IllegalAccessException exception) {
-                throw new RuntimeException("Unable to access property \"" + 
key + "\".", exception);
+                throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                    key, bean.getClass().getName()), exception);
             } catch (InvocationTargetException exception) {
-                throw new RuntimeException("Unable to access property \"" + 
key + "\".", exception.getCause());
+                throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                    key, bean.getClass().getName()), exception.getCause());
             }
         }
 
@@ -688,7 +697,8 @@ public class BeanAdapter implements Map<
                 } catch (NoSuchFieldException exception) {
                     // No-op
                 } catch (IllegalAccessException exception) {
-                    throw new RuntimeException("Unable to access property \"" 
+ key + "\".", exception);
+                    throw new 
RuntimeException(String.format(PROPERTY_EXCEPTION_MESSAGE_FORMAT,
+                        key, beanClass.getName()), exception);
                 }
             }
 


Reply via email to