You are here

protected function DrupalApacheSolrService::checkResponse in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::checkResponse()
  2. 7 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 428

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) {
    if ($code >= 400 && $code != 403 && $code != 404) {

      // Add details, like Solr's exception message.
      $response->status_message .= $response->data;
    }
    throw new Exception('"' . $code . '" Status: ' . $response->status_message);
  }
  return $response;
}