errorData = $errorData + ['error_code' => $error_code]; } /** * Custom string representation of object. * * @return string */ public function __toString() { return __CLASS__ . ": [{$this->errorData['error_code']}: {$this->message}\n"; } /** * Get error code. * * @return int|string */ public function getErrorCode() { return $this->errorData['error_code']; } /** * Return specific error information. * * (Can be used for more detailed error messages or translation.) * * This method may be overridden in child exception classes in order * to add functionality not present in PEAR_Exception and is a placeholder * to define API * * The returned array must be an associative array of parameter => value like so: *
   * array('name' => $name, 'context' => array(...))
   * 
* @return array */ public function getErrorData() { return $this->errorData; } /** * Get extra parameters. * * @return array * @deprecated Remove in v6.0. Compatibility with older API_Exception/CiviCRM_API3_Exception contracts. */ public function getExtraParams() { return $this->errorData; } /** * Get error codes. * * DIVERGENCE: API_Exception defined a discoverable list of error-codes. CRM_Core_Exception and CiviCRM_API3_Exception did not. * * @return array */ public function getErrorCodes() { return [ 2000 => '$params was not an array', 2001 => 'Invalid Value for Date field', 2100 => 'String value is longer than permitted length', self::UNAUTHORIZED => 'Unauthorized', self::NOT_IMPLEMENTED => 'Entity or method is not implemented', ]; } }