<?php
namespace Civi\API\Exception;
-require_once 'api/Exception.php';
-
/**
* Class NotImplementedException
* @package Civi\API\Exception
*/
-class NotImplementedException extends \API_Exception {
+class NotImplementedException extends \CRM_Core_Exception {
/**
* @param string $message
* A previous exception which caused this new exception.
*/
public function __construct($message, $extraParams = [], \Exception $previous = NULL) {
- parent::__construct($message, \API_Exception::NOT_IMPLEMENTED, $extraParams, $previous);
+ parent::__construct($message, \CRM_Core_Exception::NOT_IMPLEMENTED, $extraParams, $previous);
}
}
<?php
namespace Civi\API\Exception;
-require_once 'api/Exception.php';
-
/**
* Class UnauthorizedException
* @package Civi\API\Exception
*/
-class UnauthorizedException extends \API_Exception {
+class UnauthorizedException extends \CRM_Core_Exception {
/**
* @param string $message
* A previous exception which caused this new exception.
*/
public function __construct($message, $extraParams = [], \Exception $previous = NULL) {
- parent::__construct($message, \API_Exception::UNAUTHORIZED, $extraParams, $previous);
+ parent::__construct($message, \CRM_Core_Exception::UNAUTHORIZED, $extraParams, $previous);
}
}
* Array to be passed to API function.
*
* @return array|int
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
* @see runSafe
* @deprecated
*/
* Array to be passed to API function.
*
* @return array|int
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
public function runSafe($entity, $action, $params) {
$apiRequest = [];
$this->dispatcher->dispatch('civi.api.exception', new ExceptionEvent($e, NULL, $apiRequest, $this));
}
- if ($e instanceof \API_Exception) {
+ if ($e instanceof \CRM_Core_Exception) {
$err = $this->formatApiException($e, $apiRequest);
}
elseif ($e instanceof \PEAR_Exception) {
*
* @param array|\Civi\Api4\Generic\AbstractAction $apiRequest
* @return array|\Civi\Api4\Generic\Result
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\NotImplementedException
* @throws \Civi\API\Exception\UnauthorizedException
*/
* Bootstrap - Load basic dependencies and sanity-check inputs.
*
* @param \Civi\Api4\Generic\AbstractAction|array $apiRequest
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
public function boot($apiRequest) {
- require_once 'api/Exception.php';
// the create error function loads some functions from utils
// so this require is also needed for apiv4 until such time as
// we alter create error.
switch ($apiRequest['version']) {
case 3:
if (!is_array($apiRequest['params'])) {
- throw new \API_Exception('Input variable `params` is not an array', 2000);
+ throw new \CRM_Core_Exception('Input variable `params` is not an array', 2000);
}
_civicrm_api3_initialize();
break;
break;
default:
- throw new \API_Exception('Unknown api version', 2000);
+ throw new \CRM_Core_Exception('Unknown api version', 2000);
}
}
/**
* @param array $apiRequest
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
protected function validate($apiRequest) {
}
*
* @return array
* API response.
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
public function formatException($e, $apiRequest) {
$data = [];
}
/**
- * @param \API_Exception $e
+ * @param \CRM_Core_Exception $e
* An unhandled exception.
* @param array $apiRequest
* The full description of the API request.
*
* @return array
* (API response)
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
public function formatApiException($e, $apiRequest) {
$data = $e->getExtraParams();
* @return array
* API response.
*
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
public function formatPearException($e, $apiRequest) {
$data = [];
* @param mixed $code
* Doesn't appear to be used.
*
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
* @return array
* Array<type>.
*/
if (isset($apiRequest['params']) && is_array($apiRequest['params']) && !empty($apiRequest['params']['api.has_parent'])) {
$errorCode = empty($data['error_code']) ? 'chained_api_failed' : $data['error_code'];
- throw new \API_Exception('Error in call to ' . $apiRequest['entity'] . '_' . $apiRequest['action'] . ' : ' . $msg, $errorCode, $data);
+ throw new \CRM_Core_Exception('Error in call to ' . $apiRequest['entity'] . '_' . $apiRequest['action'] . ' : ' . $msg, $errorCode, $data);
}
return $data;
use Civi\Api4\Utils\CoreUtil;
use Civi\Test\HeadlessInterface;
-require_once 'api/Exception.php';
-
/**
* @group headless
*/
* @param string $entityName
* @param array $values
* @return array|null
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\NotImplementedException
*/
public function createTestRecord(string $entityName, array $values = []) {
* @param string $entityName
* @param array $saveParams
* @return \Civi\Api4\Generic\Result
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\NotImplementedException
*/
public function saveTestRecords(string $entityName, array $saveParams) {
* @param array $values
*
* @return array
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
public function getRequiredValuesToCreate(string $entity, &$values = []) {
$requiredFields = civicrm_api4($entity, 'getfields', [
return $randomValue;
}
- throw new \API_Exception('Could not provide default value');
+ throw new \CRM_Core_Exception('Could not provide default value');
}
/**
*
* @return int
*
- * @throws \API_Exception
+ * @throws \CRM_Core_Exception
*/
private function getFkID(string $fkEntity) {
$params = ['checkPermissions' => FALSE];