Merge pull request #2288 from eileenmcnaughton/CRM-14043
[civicrm-core.git] / api / v3 / examples / CustomGroupDelete.php
index 8501d1fd8b786da6ace8c147a330ae727b9db3bb..e5b7dc15e634b051c2035a408893e96bb9dbaf97 100644 (file)
@@ -1,32 +1,40 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using custom_group delete API
+ * *
  */
 function custom_group_delete_example(){
-$params = array( 
+$params = array(
   'id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'custom_group','delete',$params );
+try{
+  $result = civicrm_api3('custom_group', 'delete', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function custom_group_delete_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'values' => 1,
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }