Commit b170f01d authored by Andreas Streichardt's avatar Andreas Streichardt

Add body to HttpException (if available). Bad Request 400 is simply not...

Add body to HttpException (if available). Bad Request 400 is simply not sufficient to debug problems
parent 5c7afe1c
......@@ -75,7 +75,7 @@ class Solarium_Client_HttpException extends Solarium_Exception
* @param string $statusMessage
* @param int|null $code
*/
public function __construct($statusMessage, $code = null)
public function __construct($statusMessage, $code = null, $body = null)
{
$this->_statusMessage = $statusMessage;
......@@ -83,6 +83,9 @@ class Solarium_Client_HttpException extends Solarium_Exception
if (null !== $code) {
$message .= ' (' . $code . ')';
}
if ($body) {
$message .= "\n" . $body;
}
parent::__construct($message, $code);
}
......@@ -97,4 +100,9 @@ class Solarium_Client_HttpException extends Solarium_Exception
return $this->_statusMessage;
}
public function getBody()
{
return $this->_body;
}
}
......@@ -97,7 +97,8 @@ class Solarium_Result
if ($statusNum == 4 || $statusNum == 5) {
throw new Solarium_Client_HttpException(
$response->getStatusMessage(),
$response->getStatusCode()
$response->getStatusCode(),
$response->getBody()
);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment