improve error message

This commit is contained in:
Marc Michalsky forumZFD 2021-02-12 15:34:25 +01:00
parent 6085239f69
commit 498dc9523f
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
2 changed files with 8 additions and 4 deletions

View file

@ -57,7 +57,13 @@ function civicrm_api3_twingle_form_Create(array $params): array {
}
// Re-create TwingleProject
$result = civicrm_api3('TwingleProject', 'create', $params);
try {
$result = civicrm_api3('TwingleProject', 'create', $params);
} catch (CiviCRM_API3_Exception $e) {
$extraParams = $e->getExtraParams();
unset($extraParams['error_code']);
return civicrm_api3_create_error($e->getMessage(), $extraParams);
}
// Retrun results
if ($result['is_error'] != 1) {

View file

@ -96,9 +96,7 @@ function civicrm_api3_twingle_project_Create(array $params): array {
$project = new TwingleProject($params, $id);
}
} catch (Exception $e) {
return civicrm_api3_create_error(
'Could not instantiate TwingleProject: ' . $e->getMessage()
);
return civicrm_api3_create_error($e->getMessage(), $params);
}