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 ...@@ -75,7 +75,7 @@ class Solarium_Client_HttpException extends Solarium_Exception
* @param string $statusMessage * @param string $statusMessage
* @param int|null $code * @param int|null $code
*/ */
public function __construct($statusMessage, $code = null) public function __construct($statusMessage, $code = null, $body = null)
{ {
$this->_statusMessage = $statusMessage; $this->_statusMessage = $statusMessage;
...@@ -83,6 +83,9 @@ class Solarium_Client_HttpException extends Solarium_Exception ...@@ -83,6 +83,9 @@ class Solarium_Client_HttpException extends Solarium_Exception
if (null !== $code) { if (null !== $code) {
$message .= ' (' . $code . ')'; $message .= ' (' . $code . ')';
} }
if ($body) {
$message .= "\n" . $body;
}
parent::__construct($message, $code); parent::__construct($message, $code);
} }
...@@ -97,4 +100,9 @@ class Solarium_Client_HttpException extends Solarium_Exception ...@@ -97,4 +100,9 @@ class Solarium_Client_HttpException extends Solarium_Exception
return $this->_statusMessage; return $this->_statusMessage;
} }
} public function getBody()
\ No newline at end of file {
return $this->_body;
}
}
...@@ -97,7 +97,8 @@ class Solarium_Result ...@@ -97,7 +97,8 @@ class Solarium_Result
if ($statusNum == 4 || $statusNum == 5) { if ($statusNum == 4 || $statusNum == 5) {
throw new Solarium_Client_HttpException( throw new Solarium_Client_HttpException(
$response->getStatusMessage(), $response->getStatusMessage(),
$response->getStatusCode() $response->getStatusCode(),
$response->getBody()
); );
} }
} }
...@@ -144,4 +145,4 @@ class Solarium_Result ...@@ -144,4 +145,4 @@ class Solarium_Result
return $this->_data; return $this->_data;
} }
} }
\ No newline at end of file
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