You are here

private function GuzzleConnectionDebug::process5xxError in Elasticsearch Connector 7

Same name and namespace in other branches
  1. 7.5 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::process5xxError()
  2. 7.2 modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc \Elasticsearch\Connections\GuzzleConnectionDebug::process5xxError()

Parameters

Request $request:

ServerErrorResponseException $exception:

string $body:

Throws

\Elasticsearch\Common\Exceptions\RoutingMissingException

\Elasticsearch\Common\Exceptions\NoShardAvailableException

\Guzzle\Http\Exception\ServerErrorResponseException

\Elasticsearch\Common\Exceptions\NoDocumentsToGetException

1 call to GuzzleConnectionDebug::process5xxError()
GuzzleConnectionDebug::sendRequest in modules/elasticsearch_connector_devel/includes/GuzzleConnectionDebugging.inc

File

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

Class

GuzzleConnectionDebug

Namespace

Elasticsearch\Connections

Code

private function process5xxError(Request $request, ServerErrorResponseException $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}";
  $this->log
    ->error($exceptionText);
  if ($statusCode === 500 && strpos($responseBody, "RoutingMissingException") !== false) {
    throw new RoutingMissingException($exceptionText, $statusCode, $exception);
  }
  elseif ($statusCode === 500 && preg_match('/ActionRequestValidationException.+ no documents to get/', $responseBody) === 1) {
    throw new NoDocumentsToGetException($exceptionText, $statusCode, $exception);
  }
  elseif ($statusCode === 500 && strpos($responseBody, 'NoShardAvailableActionException') !== false) {
    throw new NoShardAvailableException($exceptionText, $statusCode, $exception);
  }
  else {
    throw new \Elasticsearch\Common\Exceptions\ServerErrorResponseException($exceptionText, $statusCode, $exception);
  }
}