diff --git a/Civi/ContactCats/Processor.php b/Civi/ContactCats/Processor.php index 416905c..7631db6 100644 --- a/Civi/ContactCats/Processor.php +++ b/Civi/ContactCats/Processor.php @@ -90,17 +90,26 @@ class Processor { \CRM_Core_Transaction::create()->run(function($tx) use (&$summary) { $this->resetTable(); foreach ($this->categories as $cat) { - if ($cat['search_type'] === 'group') { - $this->assignCategoryFromGroup($cat); + try { + if ($cat['search_type'] === 'group') { + $this->assignCategoryFromGroup($cat); + } + elseif ($cat['search_type'] === 'search') { + $this->assignCategoryFromSearch($cat); + } + elseif ($cat['search_type'] === 'default') { + $this->assignDefaultCategory($cat); + } + else { + throw new CRM_Core_Exception("Invalid search_type: $cat[search_type] for category $cat[id]"); + } } - elseif ($cat['search_type'] === 'search') { - $this->assignCategoryFromSearch($cat); - } - elseif ($cat['search_type'] === 'default') { - $this->assignDefaultCategory($cat); - } - else { - throw new CRM_Core_DAO("Invalid search_type: $cat[search_type] for category $cat[id]"); + catch (\Exception $e) { + throw new CRM_Core_Exception( + "ContactCats failed to run category $cat[id] $cat[search_type] $cat[label]: " . $e->getMessage(), + 0, + [], + $e); } // future... } @@ -267,8 +276,6 @@ class Processor { $apiParams = $search['api_params']; if ($search['api_entity'] === 'Contact' && in_array('id', $apiParams['select'] ?? [])) { $contactIdKey = 'id'; - // We only need the ID. - $apiParams['select'] = ['id']; if ($this->contact_id) { // Limit to one contact. $apiParams['where'][] = ['id', '=', $this->contact_id];