You are here

protected function SolrConnectorPluginBase::handleHttpException in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::handleHttpException()
  2. 8 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:

\Solarium\Core\Client\Endpoint $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 868

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 = $e
    ->getCode();
  switch ($response_code) {
    case 404:
      $description = 'not found';
      break;
    case 401:
    case 403:
      $description = 'access denied';
      break;
    default:
      $description = 'unreachable';
  }
  throw new SearchApiSolrException('Solr endpoint ' . $endpoint
    ->getBaseUri() . " {$description}.", $response_code, $e);
}