Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-11926 Improve error message on APi failure to include DB error message #2

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion api/api.php
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