You are here

protected function DrupalApacheSolrService::checkResponse in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::checkResponse()
  2. 6.3 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::checkResponse()

Check the reponse code and thow an exception if it's not 200.

@thows Exception

Parameters

stdClass $response: response object.

Return value

response object

3 calls to DrupalApacheSolrService::checkResponse()
DrupalApacheSolrService::makeServletRequest in ./Drupal_Apache_Solr_Service.php
Make a request to a servlet (a path) that's not a standard path.
DrupalApacheSolrService::_sendRawGet in ./Drupal_Apache_Solr_Service.php
Central method for making a GET operation against this Solr Server
DrupalApacheSolrService::_sendRawPost in ./Drupal_Apache_Solr_Service.php
Central method for making a POST operation against this Solr Server

File

./Drupal_Apache_Solr_Service.php, line 436

Class

DrupalApacheSolrService
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

protected function checkResponse($response) {
  $code = (int) $response->code;
  if ($code != 200) {

    // Report where the user's code called the apachesolr code
    $caller = $this
      ->findCaller();
    watchdog('Apache Solr', t('Environment @env_id; HTTP Status: %http_status; <br>Message: %status_message; <br>Response: %response; <br>Request: %request; <br>Caller: %function (line %line of %file)'), array(
      '@env_id' => $this
        ->getId(),
      '%http_status' => $code,
      '%status_message' => $response->status_message,
      '%response' => $response->data,
      '%request' => empty($response->request) ? t('Unknown') : $response->request,
      '%function' => isset($caller['class']) ? $caller['class'] . '->' . $caller['function'] . '()' : $caller['function'] . '()',
      '%line' => $caller['line'],
      '%file' => $caller['file'],
    ), WATCHDOG_ERROR);
    throw new Exception('HTTP ' . $code . '; ' . $response->status_message);
  }
  return $response;
}