* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ * * @package Solarium * @subpackage Client */ /** * Solarium client HTTP exception * * This exception class exists to make it easy to catch HTTP errors. * HTTP errors usually mean your Solr settings or Solr input (e.g. query) * contain an error. * * The getMessage method returns an error description that includes the status * message and code. * * The getCode method will return the HTTP response code returned by the server * (if available). * * The getStatusMessage method will return the HTTP status message. * * @package Solarium * @subpackage Client */ class Solarium_Client_HttpException extends Solarium_Exception { /** * HTTP status message * * @var string */ protected $_statusMessage; /** * Exception constructor * * The input message is a HTTP status message. Because an exception with the * message 'Not Found' is not very clear it this message is tranformed to a * more descriptive text. The original message is available using the * {@link getStatusMessage} method. * * @param string $statusMessage * @param int|null $code */ public function __construct($statusMessage, $code = null) { $this->_statusMessage = $statusMessage; $message = 'Solr HTTP error: ' . $statusMessage; if (null !== $code) { $message .= ' (' . $code . ')'; } parent::__construct($message, $code); } /** * Get the HTTP status message * * @return string */ public function getStatusMessage() { return $this->_statusMessage; } }