Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
7ac8d9ac
Commit
7ac8d9ac
authored
Apr 25, 2012
by
Larry Garfield
Browse files
Add a database wrapping exception for PDOExceptions to carry additional debug information.
parent
acf9151a
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Database/Connection.php
View file @
7ac8d9ac
...
...
@@ -524,15 +524,15 @@ public function query($query, array $args = array(), $options = array()) {
}
catch
(
PDOException
$e
)
{
if
(
$options
[
'throw_exception'
])
{
//
Add additional debug information.
if
(
$query
instanceof
DatabaseStatementInterface
)
{
$e
->
query_string
=
$stmt
->
getQueryString
()
;
}
else
{
$e
->
query_string
=
$query
;
}
$e
->
args
=
$args
;
throw
$e
;
//
Wrap the exception in another exception. Its message is the extra
// database debug information. We have to do it this way because PHP
// does not allow us to override Exception::getMessage
()
.
$query_string
=
(
$query
instanceof
DatabaseStatementInterface
)
?
$stmt
->
getQueryString
()
:
$query
;
$message
=
$e
->
getMessage
()
.
": "
.
$query_string
.
"; "
.
print_r
(
$args
,
TRUE
)
;
$exception
=
new
DatabaseExceptionWrapper
(
$message
,
0
,
$e
);
throw
$e
xception
;
}
return
NULL
;
}
...
...
core/lib/Drupal/Core/Database/DatabaseExceptionWrapper.php
0 → 100644
View file @
7ac8d9ac
<?php
/**
* @file
* Definition of Drupal\Core\Database\DatabaseExceptionWrapper
*/
namespace
Drupal\Core\Database
;
use
RuntimeException
;
/**
* This wrapper class serves only to provide additional debug information.
*
* This class will always wrap a PDOException.
*/
class
DatabaseExceptionWrapper
extends
RuntimeException
implements
DatabaseException
{
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment