You are here

protected function SolrConnectorPluginBase::handleHttpException in Search API Solr 8.3

Same name and namespace in other branches
  1. 8 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::handleHttpException()
  2. 8.2 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::handleHttpException()
  3. 4.x src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::handleHttpException()

Converts a HttpException in an easier to read SearchApiSolrException.

Parameters

\Solarium\Exception\HttpException $e: The HttpException object.

\Solarium\Core\Client\Endpoint $endpoint: The Solarium endpoint.

Throws

\Drupal\search_api_solr\SearchApiSolrException

2 calls to SolrConnectorPluginBase::handleHttpException()
SolrConnectorPluginBase::execute in src/SolrConnector/SolrConnectorPluginBase.php
Executes any query.
SolrConnectorPluginBase::executeRequest in src/SolrConnector/SolrConnectorPluginBase.php
Executes a request and returns the response.

File

src/SolrConnector/SolrConnectorPluginBase.php, line 895

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

protected function handleHttpException(HttpException $e, Endpoint $endpoint) {
  $response_code = (int) $e
    ->getCode();
  switch ((string) $response_code) {
    case '404':
      $description = 'not found';
      break;
    case '401':
    case '403':
      $description = 'access denied';
      break;
    case '500':
    case '0':
      $description = 'internal Solr server error';
      break;
    default:
      $description = 'unreachable or returned unexpected response code';
  }
  throw new SearchApiSolrException(sprintf('Solr endpoint %s %s (%d). %s', $endpoint
    ->getServerUri(), $description, $response_code, $e
    ->getBody()), $response_code, $e);
}