 includes/database/database.inc |   17 +++++++++++------
 includes/menu.inc              |    2 +-
 modules/comment/comment.module |    2 +-
 modules/node/node.module       |    2 +-
 modules/node/node.test         |    2 +-
 modules/user/user.module       |    2 +-
 6 files changed, 16 insertions(+), 11 deletions(-)

diff --git includes/database/database.inc includes/database/database.inc
index 80600bd..040fae8 100644
--- includes/database/database.inc
+++ includes/database/database.inc
@@ -834,6 +834,8 @@ abstract class DatabaseConnection extends PDO {
    *   by not concatenating dynamic values into it! Variables in the
    *   message should be added by using placeholder strings alongside
    *   the variables argument to declare the value of the placeholders.
+   *   It is also possible to pass in an exception object which will then be
+   *   decoded to get the useful information out of it.
    * @param $variables
    *   Array of variables to replace in the message on display or
    *   NULL if message is already translated or not possible to
@@ -864,6 +866,13 @@ abstract class DatabaseConnection extends PDO {
       }
     }
 
+    // If the message is actually an exception, decode it to get the necessary
+    // information.
+    if ($message instanceof Exception) {
+      $variables += _drupal_decode_exception($message);
+      $message = '%type: %message in %function (line %line of %file).';
+    }
+
     // Record in an array to send to the log after transaction rollback.
     // Messages written directly to a log (with a database back-end) will roll
     // back during the following transaction rollback. This is an array because
@@ -1688,6 +1697,8 @@ class DatabaseTransaction {
    *   concatenating dynamic values into it! Variables in the message should be
    *   added by using placeholder strings alongside the variable's argument to
    *   declare the value of the placeholders.
+   *   It is also possible to pass in an exception object which will then be
+   *   decoded to get the useful information out of it.
    * @param $variables
    *   Array of variables to replace in the message on display or NULL if the
    *   message is already translated or not possible to translate.
@@ -1701,12 +1712,6 @@ class DatabaseTransaction {
    */
   public function rollback($type = NULL, $message = NULL, $variables = array(), $severity = NULL, $link = NULL) {
     $this->rolledBack = TRUE;
-    if (!isset($severity)) {
-      $logging = Database::getLoggingCallback();
-      if (is_array($logging)) {
-        $severity = $logging['default_severity'];
-      }
-    }
     $this->connection->rollback($this->name, $type, $message, $variables, $severity, $link);
   }
 }
diff --git includes/menu.inc includes/menu.inc
index 3c355ce..a67caec 100644
--- includes/menu.inc
+++ includes/menu.inc
@@ -2300,7 +2300,7 @@ function menu_rebuild() {
     }
   }
   catch (Exception $e) {
-    $transaction->rollback('menu', $e->getMessage(), array(), WATCHDOG_ERROR);
+    $transaction->rollback('menu', $e, array(), WATCHDOG_ERROR);
   }
 
   lock_release('menu_rebuild');
diff --git modules/comment/comment.module modules/comment/comment.module
index 6eb90cd..2b3c8bf 100644
--- modules/comment/comment.module
+++ modules/comment/comment.module
@@ -1508,7 +1508,7 @@ function comment_save($comment) {
     }
   }
   catch (Exception $e) {
-    $transaction->rollback('comment', $e->getMessage(), array(), WATCHDOG_ERROR);
+    $transaction->rollback('comment', $e, array(), WATCHDOG_ERROR);
   }
 
 }
diff --git modules/node/node.module modules/node/node.module
index 7668f32..af95c95 100644
--- modules/node/node.module
+++ modules/node/node.module
@@ -1085,7 +1085,7 @@ function node_save($node) {
     db_ignore_slave();
   }
   catch (Exception $e) {
-    $transaction->rollback('node', $e->getMessage(), array(), WATCHDOG_ERROR);
+    $transaction->rollback('node', $e, array(), WATCHDOG_ERROR);
   }
 }
 
diff --git modules/node/node.test modules/node/node.test
index f8139c3..6b0af66 100644
--- modules/node/node.test
+++ modules/node/node.test
@@ -480,7 +480,7 @@ class NodeCreationTestCase extends DrupalWebTestCase {
     }
 
     // Check that the rollback error was logged.
-    $records = db_query("SELECT wid FROM {watchdog} WHERE message LIKE 'Test exception for rollback.'")->fetchAll();
+    $records = db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll();
     $this->assertTrue(count($records) > 0, t('Rollback explanatory error logged to watchdog.'));
   }
 }
diff --git modules/user/user.module modules/user/user.module
index 51e4db5..8f73879 100644
--- modules/user/user.module
+++ modules/user/user.module
@@ -524,7 +524,7 @@ function user_save($account, $edit = array(), $category = 'account') {
     return $user;
   }
   catch (Exception $e) {
-    $transaction->rollback('user', $e->getMessage(), array(), WATCHDOG_ERROR);
+    $transaction->rollback('user', $e, array(), WATCHDOG_ERROR);
   }
 }
 
