From aadb4246f51100e7a76b02af353bd55307f9e681 Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Thu, 17 Dec 2020 10:45:16 +0100 Subject: [PATCH] fix error message for TwingleForm.Get --- api/v3/TwingleForm/Get.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/v3/TwingleForm/Get.php b/api/v3/TwingleForm/Get.php index be52db7..d310095 100644 --- a/api/v3/TwingleForm/Get.php +++ b/api/v3/TwingleForm/Get.php @@ -55,6 +55,7 @@ function _civicrm_api3_twingle_form_Get_spec(array &$spec) { * */ function civicrm_api3_twingle_form_Get(array $params): array { + $returnValues = []; // Get custom fields $custom_field_mapping = Cache::getInstance()->getCustomFieldMapping(); @@ -78,7 +79,6 @@ function civicrm_api3_twingle_form_Get(array $params): array { $result = civicrm_api3('Campaign', 'get', $request); if ($result['is_error'] == 0) { - $returnValues = []; foreach($result['values'] as $value) { array_push( $returnValues, @@ -96,10 +96,9 @@ function civicrm_api3_twingle_form_Get(array $params): array { return civicrm_api3_create_success($returnValues, $params, 'TwingleForm', 'Get'); } else { - // TODO: Edit error message - throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect'); + return civicrm_api3_create_error($result['message']); } } catch (Exception $e) { - throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect'); + throw new API_Exception($e->getMessage()); } }