db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r537753 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc: EmbedConnection.java Util.java
Date Mon, 14 May 2007 08:51:03 GMT
Author: kahatlen
Date: Mon May 14 01:51:02 2007
New Revision: 537753

URL: http://svn.apache.org/viewvc?view=rev&rev=537753
Log:
DERBY-2472 (partial) Use Throwable.initCause() to improve error reporting

Chain exceptions from EmbedConnection.createDatabase() and
EmbedConnection.bootDatabase() properly.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?view=diff&rev=537753&r1=537752&r2=537753
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Mon May
14 01:51:02 2007
@@ -1760,10 +1760,9 @@
 				addWarning(EmbedSQLWarning.newEmbedSQLWarning(SQLState.DATABASE_EXISTS, dbname));
 			}
 		} catch (StandardException mse) {
-
-			SQLException se = newSQLException(SQLState.CREATE_DATABASE_FAILED, dbname);
-			se.setNextException(handleException(mse));
-			throw se;
+            throw Util.seeNextException(SQLState.CREATE_DATABASE_FAILED,
+                                        new Object[] { dbname },
+                                        handleException(mse));
 		}
 
 		// clear these values as some modules hang onto
@@ -1810,7 +1809,6 @@
 			tr.setDatabase(database);
 
 		} catch (StandardException mse) {
-			SQLException se = newSQLException(SQLState.BOOT_DATABASE_FAILED, dbname);
 
 			Throwable ne = mse.getCause();
 			SQLException nse;
@@ -1833,8 +1831,8 @@
 			else
 				nse = Util.generateCsSQLException(mse);
 
-			se.setNextException(nse);
-			throw se;
+            throw Util.seeNextException(SQLState.BOOT_DATABASE_FAILED,
+                                        new Object[] { dbname }, nse);
 		}
 
 		// If database exists, getDatabase() will return the database object.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?view=diff&rev=537753&r1=537752&r2=537753
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Mon May 14 01:51:02
2007
@@ -209,6 +209,22 @@
         		StandardException.getSeverityFromIdentifier(SQLState.NO_CURRENT_CONNECTION));
 	}
 
+    /**
+     * Generate an <code>SQLException</code> which points to another
+     * <code>SQLException</code> nested within it with
+     * <code>setNextException()</code>.
+     *
+     * @param messageId message id
+     * @param args the arguments to the message creation
+     * @param next the next SQLException
+     * @return an SQLException wrapping another SQLException
+     */
+    static SQLException seeNextException(String messageId, Object[] args,
+                                         SQLException next) {
+        return newEmbedSQLException(messageId, args, next,
+            StandardException.getSeverityFromIdentifier(messageId), null);
+    }
+
 	public static SQLException javaException(Throwable t) {
 		String name, msg;
 



Mime
View raw message