donaldp     01/11/01 01:13:56

  Modified:    src/java/org/apache/avalon/framework/configuration
                        AbstractConfiguration.java
                        DefaultConfiguration.java
  Log:
  Here's another patch for Configuration : it adds location information to
  every ConfigurationException thrown, and also erroneous values for parse
  failures. This is really usefull for debugging.
  
  Submitted By: Sylvain Wallez <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.6       +25 -25    
jakarta-avalon/src/java/org/apache/avalon/framework/configuration/AbstractConfiguration.java
  
  Index: AbstractConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/AbstractConfiguration.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractConfiguration.java        2001/10/02 16:24:55     1.5
  +++ AbstractConfiguration.java        2001/11/01 09:13:56     1.6
  @@ -15,7 +15,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2001/10/02 16:24:55 $
  + * @version CVS $Revision: 1.6 $ $Date: 2001/11/01 09:13:56 $
    */
   public abstract class AbstractConfiguration
       implements Configuration
  @@ -54,9 +54,9 @@
           }
           catch( final Exception nfe )
           {
  -            throw
  -                new ConfigurationException( "Cannot parse the value of the 
configuration " +
  -                                            "element \"" + getName() + "\" 
as an integer" );
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as an integer in the 
configuration element \"" +
  +                                              getName() + " at " + 
getLocation() );
           }
       }
   
  @@ -115,9 +115,9 @@
           }
           catch( final Exception nfe )
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
" +
  -                                              "configuration element \"" + 
getName() +
  -                                              "\" as a long" );
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as a long in the 
configuration element \"" +
  +                                              getName() + " at " + 
getLocation() );
           }
       }
   
  @@ -158,9 +158,9 @@
           }
           catch( final Exception nfe )
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
" +
  -                                              "configuration element \"" + 
getName() +
  -                                              "\" as a float" );
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as a float in the 
configuration element \"" +
  +                                              getName() + " at " + 
getLocation() );
           }
       }
   
  @@ -202,9 +202,9 @@
           }
           else
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
" +
  -                                              "configuration element \"" +
  -                                              getName() + "\" as a boolean" 
);
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as a boolean in the 
configuration element \"" +
  +                                              getName() + " at " + 
getLocation() );
           }
       }
   
  @@ -280,9 +280,9 @@
           }
           catch( final Exception nfe )
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
attribute \"" +
  -                                              name + "\" of the 
configuration element \"" +
  -                                              getName() + "\" as an integer" 
);
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as an integer in the 
attribute \"" + 
  +                                              name + " at " + getLocation() 
);
           }
       }
   
  @@ -346,9 +346,9 @@
           }
           catch( final Exception nfe )
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
attribute \"" +
  -                                              name + "\" of the 
configuration element \"" +
  -                                              getName() + "\" as a long" );
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as a long in the attribute 
\"" + 
  +                                              name + " at " + getLocation() 
);
           }
       }
   
  @@ -393,9 +393,9 @@
           }
           catch( final Exception e )
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
attribute \"" +
  -                                              name + "\" of the 
configuration element \"" +
  -                                              getName() + "\" as a float" );
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as a float in the 
attribute \"" + 
  +                                              name + " at " + getLocation() 
);
           }
       }
   
  @@ -442,9 +442,9 @@
           }
           else
           {
  -            throw new ConfigurationException( "Cannot parse the value of the 
attribute \"" +
  -                                              name + "\" of the 
configuration element \"" +
  -                                              getName() + "\" as a boolean" 
);
  +            throw new ConfigurationException( "Cannot parse the value \"" + 
value +
  +                                              "\" as a boolean in the 
attribute \"" + 
  +                                              name + " at " + getLocation() 
);
           }
       }
   
  
  
  
  1.7       +3 -2      
jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java
  
  Index: DefaultConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultConfiguration.java 2001/10/02 16:24:55     1.6
  +++ DefaultConfiguration.java 2001/11/01 09:13:56     1.7
  @@ -89,7 +89,8 @@
           else
           {
               throw new ConfigurationException( "No value is associated with 
the "+
  -                                              "configuration element \"" + 
getName() + "\"" );
  +                                              "configuration element \"" + 
getName() +
  +                                              " at " + getLocation() );
           }
       }
   
  @@ -146,7 +147,7 @@
           {
               throw new ConfigurationException( "No attribute named \"" + name 
+ "\" is " +
                                                 "associated with the 
configuration element \"" +
  -                                              getName() + "\"" );
  +                                              getName() + " at " + 
getLocation() );
           }
       }
   
  
  
  

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

Reply via email to