Skip to content

Commit

Permalink
CRM-11926 add a better error handling for db errors in the api
Browse files Browse the repository at this point in the history
  • Loading branch information
tttp committed Mar 1, 2013
1 parent 1e67383 commit f198bd7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ function civicrm_api($entity, $action, $params, $extra = NULL) {
if (CRM_Utils_Array::value('format.is_success', $apiRequest['params']) == 1) {
return 0;
}
$error = $e->getCause();
if ($error instanceof DB_Error) {
$data["error_code"] = DB::errorMessage($error->getCode());
$data["sql"] = $error->getDebugInfo();
}
if (CRM_Utils_Array::value('debug', $apiRequest['params'])) {
$error = $e->getCause();
$data['debug_info'] = $error->getUserInfo();
$data['trace'] = $e->getTraceAsString();
}
Expand Down

0 comments on commit f198bd7

Please sign in to comment.