diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php
index d99104c20273..1f0b4d40dbf2 100644
--- a/CRM/Core/Error.php
+++ b/CRM/Core/Error.php
@@ -803,16 +803,19 @@ public static function formatHtmlException(Exception $e) {
if ($e instanceof PEAR_Exception) {
$ei = $e;
while (is_callable([$ei, 'getCause'])) {
- if ($ei->getCause() instanceof PEAR_Error) {
- $msg .= '
';
- $msg .= sprintf('%s | %s |
', ts('Error Field'), ts('Error Value'));
- $msg .= '';
- foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) {
- $msg .= sprintf('%s | %s |
', $f, call_user_func([$ei->getCause(), "get$f"]));
+ // DB_ERROR doesn't have a getCause but does have a __call function which tricks is_callable.
+ if (!$ei instanceof DB_Error) {
+ if ($ei->getCause() instanceof PEAR_Error) {
+ $msg .= '';
+ $msg .= sprintf('%s | %s |
', ts('Error Field'), ts('Error Value'));
+ $msg .= '';
+ foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) {
+ $msg .= sprintf('%s | %s |
', $f, call_user_func([$ei->getCause(), "get$f"]));
+ }
+ $msg .= '
';
}
- $msg .= '
';
+ $ei = $ei->getCause();
}
- $ei = $ei->getCause();
}
$msg .= $e->toHtml();
}
@@ -835,12 +838,19 @@ public static function formatTextException(Exception $e) {
$ei = $e;
while (is_callable([$ei, 'getCause'])) {
- if ($ei->getCause() instanceof PEAR_Error) {
- foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) {
- $msg .= sprintf(" * ERROR %s: %s\n", strtoupper($f), call_user_func([$ei->getCause(), "get$f"]));
+ // DB_ERROR doesn't have a getCause but does have a __call function which tricks is_callable.
+ if (!$ei instanceof DB_Error) {
+ if ($ei->getCause() instanceof PEAR_Error) {
+ foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) {
+ $msg .= sprintf(" * ERROR %s: %s\n", strtoupper($f), call_user_func([$ei->getCause(), "get$f"]));
+ }
}
+ $ei = $ei->getCause();
+ }
+ // if we have reached a DB_Error assume that is the end of the road.
+ else {
+ $ei = NULL;
}
- $ei = $ei->getCause();
}
$msg .= self::formatBacktrace($e->getTrace());
return $msg;