dev/core#2646 juice up the error a little
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 9 Jun 2021 19:34:06 +0000 (07:34 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 9 Jun 2021 19:34:06 +0000 (07:34 +1200)
On explaining the issue in https://lab.civicrm.org/dev/core/-/issues/2646 not
having the name of the failed entity in the error message seemed like a pain point

CRM/Core/ManagedEntities.php

index 4c70ce10e82eeb0d9952c9cfa8157441b4d802d0..3ed9c14388317baeb805060b980e0325d937f62b 100644 (file)
@@ -261,7 +261,7 @@ class CRM_Core_ManagedEntities {
    */
   public function updateExistingEntity($dao, $todo) {
     $policy = CRM_Utils_Array::value('update', $todo, 'always');
-    $doUpdate = ($policy == 'always');
+    $doUpdate = ($policy === 'always');
 
     if ($doUpdate) {
       $defaults = ['id' => $dao->entity_id];
@@ -481,7 +481,9 @@ class CRM_Core_ManagedEntities {
       'params' => $params,
       'result' => $result,
     ]);
-    throw new Exception('API error: ' . $result['error_message'] . ' on ' . $entity . '.' . $action);
+    throw new Exception('API error: ' . $result['error_message'] . ' on ' . $entity . '.' . $action
+      . !empty($params['name']) ? '( entity name ' . $params['name'] . ')' : ''
+    );
   }
 
   /**