dgraham     2003/10/21 21:14:32

  Modified:    dbutils/src/java/org/apache/commons/dbutils
                        BasicRowProcessor.java
  Log:
  Throw SQLException instead of DbException so we can get rid of our
  own seldom used exception class.
  
  Revision  Changes    Path
  1.2       +25 -17    
jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
  
  Index: BasicRowProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/BasicRowProcessor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicRowProcessor.java    18 Oct 2003 19:02:22 -0000      1.1
  +++ BasicRowProcessor.java    22 Oct 2003 04:14:32 -0000      1.2
  @@ -248,17 +248,18 @@
        * @param pd The property to set.
        * @param target The object to set the property on.
        * @param value The value to pass into the setter.
  -     * @throws DbException if an error occurs setting the property.
  +     * @throws SQLException if an error occurs setting the property.
        */
  -    private void callSetter(PropertyDescriptor pd, Object target, Object value) {
  +    private void callSetter(PropertyDescriptor pd, Object target, Object value)
  +        throws SQLException {
  +            
           Method setter = pd.getWriteMethod();
   
           if (setter == null) {
               return;
           }
  -        
  -        Class[] params = setter.getParameterTypes();
   
  +        Class[] params = setter.getParameterTypes();
           try {
               // Don't call setter if the value object isn't the right type 
               if (value == null || params[0].isInstance(value)) {
  @@ -266,11 +267,16 @@
               }
   
           } catch (IllegalArgumentException e) {
  -            throw new DbException("Cannot set " + pd.getName(), e);
  +            throw new SQLException(
  +                "Cannot set " + pd.getName() + ": " + e.getMessage());
  +
           } catch (IllegalAccessException e) {
  -            throw new DbException("Cannot set " + pd.getName(), e);
  +            throw new SQLException(
  +                "Cannot set " + pd.getName() + ": " + e.getMessage());
  +
           } catch (InvocationTargetException e) {
  -            throw new DbException("Cannot set " + pd.getName(), e);
  +            throw new SQLException(
  +                "Cannot set " + pd.getName() + ": " + e.getMessage());
           }
       }
   
  @@ -278,17 +284,19 @@
        * Returns a new instance of the given Class.
        * @param c The Class to create an object from.
        * @return A newly created object of the Class.
  -     * @throws DbException if creation failed.
  +     * @throws SQLException if creation failed.
        */
  -    private Object newInstance(Class c) {
  +    private Object newInstance(Class c) throws SQLException {
           try {
               return c.newInstance();
   
           } catch (InstantiationException e) {
  -            throw new DbException("Cannot create " + c.getName(), e);
  +            throw new SQLException(
  +                "Cannot create " + c.getName() + ": " + e.getMessage());
   
           } catch (IllegalAccessException e) {
  -            throw new DbException("Cannot create " + c.getName(), e);
  +            throw new SQLException(
  +                "Cannot create " + c.getName() + ": " + e.getMessage());
           }
       }
   
  @@ -296,16 +304,16 @@
        * Returns a PropertyDescriptor[] for the given Class.
        * @param c The Class to retrieve PropertyDescriptors for.
        * @return A PropertyDescriptor[] describing the Class.
  -     * @throws DbException if introspection failed.
  +     * @throws SQLException if introspection failed.
        */
  -    private PropertyDescriptor[] propertyDescriptors(Class c) {
  +    private PropertyDescriptor[] propertyDescriptors(Class c) throws SQLException {
           // Introspector caches BeanInfo classes for better performance
           BeanInfo beanInfo = null;
           try {
               beanInfo = Introspector.getBeanInfo(c);
   
           } catch (IntrospectionException e) {
  -            throw new DbException(e);
  +            throw new SQLException("Bean introspection failed: " + e.getMessage());
           }
   
           return beanInfo.getPropertyDescriptors();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to