You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2007/05/14 10:51:03 UTC
svn commit: r537753 - in
/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc:
EmbedConnection.java Util.java
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;