mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
RestApiResponse: response code handling
This commit is contained in:
parent
228f72db91
commit
95cb1498bc
@ -34,7 +34,19 @@ class RestApiResponse
|
||||
|
||||
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user