RestApiResponse: response code handling
This commit is contained in:
parent
228f72db91
commit
95cb1498bc
|
@ -34,7 +34,19 @@ class RestApiResponse
|
||||||
|
|
||||||
public function getSingleResult()
|
public function getSingleResult()
|
||||||
{
|
{
|
||||||
return $this->results[0]->result;
|
if ($this->isErrorCode($this->results[0]->code)) {
|
||||||
|
throw new IcingaException(
|
||||||
|
$this->results[0]->status
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return $this->results[0]->result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isErrorCode($code)
|
||||||
|
{
|
||||||
|
$code = (int) ceil($code);
|
||||||
|
return $code >= 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function extractResult($results, $desiredKey, $filter = array())
|
protected function extractResult($results, $desiredKey, $filter = array())
|
||||||
|
|
Loading…
Reference in New Issue