diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-06-01 16:47:06 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-06-01 16:47:06 +0000 |
commit | 00271e741f7d4825c76b1db21a7c55b250f209e9 (patch) | |
tree | 48a9ccf6abc25e43ba6a9049eae6245321b3ae1c /includes/database | |
parent | 8a0e218d32701d75c8ebb3c1d99b090f6f611f96 (diff) | |
download | brdo-00271e741f7d4825c76b1db21a7c55b250f209e9.tar.gz brdo-00271e741f7d4825c76b1db21a7c55b250f209e9.tar.bz2 |
- Patch #458176 by c960657: improved exception handling in database layer.
Diffstat (limited to 'includes/database')
-rw-r--r-- | includes/database/database.inc | 8 | ||||
-rw-r--r-- | includes/database/pgsql/database.inc | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc index 60d4b415f..f1185c77a 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -595,13 +595,15 @@ abstract class DatabaseConnection extends PDO { catch (PDOException $e) { _db_check_install_needed(); if ($options['throw_exception']) { + // Add additional debug information. if ($query instanceof DatabaseStatementInterface) { - $query_string = $stmt->getQueryString(); + $e->query_string = $stmt->getQueryString(); } else { - $query_string = $query; + $e->query_string = $query; } - throw new PDOException($query_string . " - \n" . print_r($args, 1) . $e->getMessage()); + $e->args = $args; + throw $e; } return NULL; } diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc index ba82aa0b0..0f5627c2a 100644 --- a/includes/database/pgsql/database.inc +++ b/includes/database/pgsql/database.inc @@ -80,13 +80,15 @@ class DatabaseConnection_pgsql extends DatabaseConnection { catch (PDOException $e) { _db_check_install_needed(); if ($options['throw_exception']) { + // Add additional debug information. if ($query instanceof DatabaseStatementInterface) { - $query_string = $stmt->getQueryString(); + $e->query_string = $stmt->getQueryString(); } else { - $query_string = $query; + $e->query_string = $query; } - throw new PDOException($query_string . " - \n" . print_r($args, 1) . $e->getMessage()); + $e->args = $args; + throw $e; } return NULL; } |