Add user friendly error message on merge error
authorJitendra Purohit <jitendra@fuzion.co.nz>
Mon, 20 Jan 2020 05:56:47 +0000 (11:26 +0530)
committerJitendra Purohit <jitendra@fuzion.co.nz>
Tue, 21 Jan 2020 03:59:40 +0000 (09:29 +0530)
CRM/Contact/Form/Merge.php

index 326a035508cab5f6a9530ca239888f01a294b3c0..2c3d2cb35cd02cfbae63678787d6b7ad2def141c 100644 (file)
@@ -87,11 +87,16 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
       if (!$this->_rgid) {
         // Unset browse URL as we have come from the search screen.
         $browseUrl = '';
-        $this->_rgid = civicrm_api3('RuleGroup', 'getvalue', [
-          'contact_type' => $this->_contactType,
-          'used' => 'Supervised',
-          'return' => 'id',
-        ]);
+        try {
+          $this->_rgid = civicrm_api3('RuleGroup', 'getvalue', [
+            'contact_type' => $this->_contactType,
+            'used' => 'Supervised',
+            'return' => 'id',
+          ]);
+        }
+        catch (Exception $e) {
+          throw new CRM_Core_Exception(ts('There is no Supervised dedupe rule configured for contact type %1.', [1 => $this->_contactType]));
+        }
       }
       $this->assign('browseUrl', $browseUrl);
       if ($browseUrl) {