From 8dbc841b8d0f5b8780251ff55385c62ef24fbb64 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 14 Sep 2023 07:43:27 +1200 Subject: [PATCH] Remove legacy error handling Our practice now is to throw exceptions - this results in a hard fatal within apiv4 usage --- CRM/Contribute/BAO/ContributionRecur.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 23d39173ed..7e05290010 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -38,14 +38,16 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi * Takes an associative array and creates a contribution object. * * the function extract all the params it needs to initialize the create a - * contribution object. the params array could contain additional unused name/value - * pairs + * contribution object. the params array could contain additional unused + * name/value pairs * * @param array $params * (reference ) an assoc array of name/value pairs. * - * @return \CRM_Contribute_BAO_ContributionRecur|\CRM_Core_Error - * @todo move hook calls / extended logic to create - requires changing calls to call create not add + * @return \CRM_Contribute_BAO_ContributionRecur + * @throws \CRM_Core_Exception + * @todo move hook calls / extended logic to create - requires changing calls + * to call create not add */ public static function add(&$params) { if (!empty($params['id'])) { @@ -59,14 +61,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi // or invoice ID as an existing recurring contribution $duplicates = []; if (self::checkDuplicate($params, $duplicates)) { - $error = CRM_Core_Error::singleton(); - $d = implode(', ', $duplicates); - $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, - 'Fatal', - [$d], - "Found matching recurring contribution(s): $d" - ); - return $error; + throw new CRM_Core_Exception("Found matching recurring contribution(s): implode(', ', $duplicates)"); } $recurring = new CRM_Contribute_BAO_ContributionRecur(); -- 2.25.1