You are here

private function GuzzleConnectionDebug::process4xxError in Elasticsearch Connector 7.5

Same name and namespace in other branches
  1. 7 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::process4xxError()
  2. 7.2 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::process4xxError()
1 call to GuzzleConnectionDebug::process4xxError()
GuzzleConnectionDebug::sendRequest in modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc

File

modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc, line 249

Class

GuzzleConnectionDebug

Namespace

Elasticsearch\Connections

Code

private function process4xxError(Request $request, ClientErrorResponseException $exception, $body) {
  $this
    ->logErrorDueToFailure($request, $exception, $body);
  $statusCode = $request
    ->getResponse()
    ->getStatusCode();
  $exceptionText = $exception
    ->getMessage();
  $responseBody = $request
    ->getResponse()
    ->getBody(true);
  $exceptionText = "{$statusCode} Server Exception: {$exceptionText}\n{$responseBody}";
  if ($statusCode === 400 && strpos($responseBody, "AlreadyExpiredException") !== false) {
    throw new AlreadyExpiredException($exceptionText, $statusCode, $exception);
  }
  elseif ($statusCode === 403) {
    throw new Forbidden403Exception($exceptionText, $statusCode, $exception);
  }
  elseif ($statusCode === 404) {
    throw new Missing404Exception($exceptionText, $statusCode, $exception);
  }
  elseif ($statusCode === 409) {
    throw new Conflict409Exception($exceptionText, $statusCode, $exception);
  }
  elseif ($statusCode === 400 && strpos($responseBody, 'script_lang not supported') !== false) {
    throw new ScriptLangNotSupportedException($exceptionText . $statusCode);
  }
}