X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FContact%2FFormatIsSuccess_Fail.php;h=60dad237bea97bf53ba5eb3d4ee472b8b0932aa5;hb=b259a4ab1e349db53f15beb4c1e9808b58dba765;hp=af4e1cc5c1542a84fcd0dd9bf3d46b97a260f568;hpb=6a4880350680e1e4d20e5c8a622a791f926ca750;p=civicrm-core.git diff --git a/api/v3/examples/Contact/FormatIsSuccess_Fail.php b/api/v3/examples/Contact/FormatIsSuccess_Fail.php index af4e1cc5c1..60dad237be 100644 --- a/api/v3/examples/Contact/FormatIsSuccess_Fail.php +++ b/api/v3/examples/Contact/FormatIsSuccess_Fail.php @@ -1,29 +1,37 @@ 3, +$params = array( 'id' => 500, 'format.is_success' => 1, ); - $result = civicrm_api( 'contact','create',$params ); +try{ + $result = civicrm_api3('contact', 'create', $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 contact_create_expectedresult(){ $expectedResult = 0; - return $expectedResult ; + return $expectedResult; } @@ -47,4 +55,4 @@ function contact_create_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/