make exceptions from searchkit easier to find

This commit is contained in:
Rich Lott / Artful Robot 2025-04-02 10:56:54 +01:00
parent c2546732b5
commit 3b42e99a96

View file

@ -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];