Skip to content

Commit

Permalink
Merge pull request #5 from tttp/CRM-11926_upstream
Browse files Browse the repository at this point in the history
CRM-11926 add a better error handling for db errors in the api
  • Loading branch information
kurund committed Mar 1, 2013
2 parents 59535ee + c56bd79 commit a544cd3
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 a544cd3

Please sign in to comment.