jmcnally    2002/06/22 15:04:22

  Modified:    src/java/org/apache/torque Torque.java
               src/java/org/apache/torque/util BasePeer.java
  Log:
  try to give some better error messages than the default npe.
  
  Revision  Changes    Path
  1.63      +25 -5     jakarta-turbine-torque/src/java/org/apache/torque/Torque.java
  
  Index: Torque.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/Torque.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- Torque.java       22 Jun 2002 21:34:38 -0000      1.62
  +++ Torque.java       22 Jun 2002 22:04:21 -0000      1.63
  @@ -838,14 +838,24 @@
           throws TorqueException
       {
           Connection con = null;
  +        DataSourceFactory dsf = null;
           try
           {
  -            DataSourceFactory dsf = (DataSourceFactory)dsFactoryMap.get(name);
  +            dsf = (DataSourceFactory)dsFactoryMap.get(name);
               con = dsf.getDataSource().getConnection(username, password);
           }
           catch (Exception e)
           {
  -            throw new TorqueException(e);
  +             if (dsf == null && e instanceof NullPointerException)
  +             {
  +                 throw new NullPointerException(
  +                     "There was no DataSourceFactory "
  +                     + "configured for the connection " + name);
  +             }
  +             else 
  +             {
  +                 throw new TorqueException(e);                 
  +             }
           }
           return con;
       }
  @@ -854,14 +864,24 @@
           throws TorqueException
       {
           Connection con = null;
  +        DataSourceFactory dsf = null;
           try
           {
  -            DataSourceFactory dsf = (DataSourceFactory)dsFactoryMap.get(name);
  +            dsf = (DataSourceFactory)dsFactoryMap.get(name);
               con = dsf.getDataSource().getConnection();
           }
           catch (Exception e)
           {
  -            throw new TorqueException(e);
  +             if (dsf == null && e instanceof NullPointerException)
  +             {
  +                 throw new NullPointerException(
  +                     "There was no DataSourceFactory "
  +                     + "configured for the connection " + name);
  +             }
  +             else 
  +             {
  +                 throw new TorqueException(e);                 
  +             }
           }
           return con;
       }
  
  
  
  1.46      +9 -1      
jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java
  
  Index: BasePeer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- BasePeer.java     22 Jun 2002 18:20:35 -0000      1.45
  +++ BasePeer.java     22 Jun 2002 22:04:22 -0000      1.46
  @@ -419,6 +419,14 @@
       public static void rollBackTransaction(Connection con)
           throws TorqueException
       {
  +        if (con == null) 
  +        {
  +            throw new NullPointerException("Connection object was null. " +
  +                "This could be due to a misconfiguration of the " + 
  +                "DataSourceFactory.  Check the logs and Torque.properties " +
  +                "to better determine the cause.");
  +        }
  +        
           try
           {
               if ( con.getMetaData().supportsTransactions() )
  
  
  

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

Reply via email to