You are here

protected function RestClient::getErrorData in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getErrorData()
  2. 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getErrorData()

Extract normalized error information from a RequestException.

Parameters

\GuzzleHttp\Exception\RequestException $e: Exception object.

Return value

array Error array with keys:

  • message
  • errorCode
  • fields

File

src/Rest/RestClient.php, line 354

Class

RestClient
Objects, properties, and methods to communicate with the Salesforce REST API.

Namespace

Drupal\salesforce\Rest

Code

protected function getErrorData(RequestException $e) {
  $response = $e
    ->getResponse();
  $response_body = $response
    ->getBody()
    ->getContents();
  $data = $this->json
    ->decode($response_body);
  if (!empty($data[0])) {
    $data = $data[0];
  }
  return $data;
}