X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FContact%2FFormatSingleValue.php;h=65cd12fc95d21b350853102ff93e08a3537869ac;hb=3ec6e38dc05990db0f98aa17b3a8d5271c5e30ab;hp=252829cdde475d94f22bf59248950369b131894d;hpb=4d20ef52acecafc3c3aa0f22b8268e5468352022;p=civicrm-core.git diff --git a/api/v3/examples/Contact/FormatSingleValue.php b/api/v3/examples/Contact/FormatSingleValue.php index 252829cdde..65cd12fc95 100644 --- a/api/v3/examples/Contact/FormatSingleValue.php +++ b/api/v3/examples/Contact/FormatSingleValue.php @@ -1,30 +1,38 @@ 3, 'id' => 17, 'return' => 'display_name', ); - $result = civicrm_api( 'contact','getvalue',$params ); +try{ + $result = civicrm_api3('contact', 'getvalue', $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_getvalue_expectedresult(){ $expectedResult = 'Test Contact'; - return $expectedResult ; + return $expectedResult; } @@ -48,4 +56,4 @@ function contact_getvalue_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/