diff --git a/api/v3/TwingleForm/Create.php b/api/v3/TwingleForm/Create.php index 49b9e39..61bdafb 100644 --- a/api/v3/TwingleForm/Create.php +++ b/api/v3/TwingleForm/Create.php @@ -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) { diff --git a/api/v3/TwingleProject/Create.php b/api/v3/TwingleProject/Create.php index 21b1280..4092e6d 100644 --- a/api/v3/TwingleProject/Create.php +++ b/api/v3/TwingleProject/Create.php @@ -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); }