if ($e instanceof PEAR_Exception) {
$ei = $e;
while (is_callable([$ei, 'getCause'])) {
- if ($ei->getCause() instanceof PEAR_Error) {
- $msg .= '<table class="crm-db-error">';
- $msg .= sprintf('<thead><tr><th>%s</th><th>%s</th></tr></thead>', ts('Error Field'), ts('Error Value'));
- $msg .= '<tbody>';
- foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) {
- $msg .= sprintf('<tr><td>%s</td><td>%s</td></tr>', $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 .= '<table class="crm-db-error">';
+ $msg .= sprintf('<thead><tr><th>%s</th><th>%s</th></tr></thead>', ts('Error Field'), ts('Error Value'));
+ $msg .= '<tbody>';
+ foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) {
+ $msg .= sprintf('<tr><td>%s</td><td>%s</td></tr>', $f, call_user_func([$ei->getCause(), "get$f"]));
+ }
+ $msg .= '</tbody></table>';
}
- $msg .= '</tbody></table>';
+ $ei = $ei->getCause();
}
- $ei = $ei->getCause();
}
$msg .= $e->toHtml();
}
$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;