RestApiResponse: throw error on error result

This commit is contained in:
Thomas Gelf 2016-03-18 13:49:42 +01:00
parent 5e3fe5e2df
commit f10ee539c8
1 changed files with 7 additions and 0 deletions

View File

@ -87,6 +87,13 @@ class RestApiResponse
$this->setJsonError();
throw new IcingaException('Parsing JSON result failed: ' . $this->errorMessage);
}
if (property_exists($result, 'error')) {
if (property_exists($result, 'status')) {
throw new IcingaException('API request failed: ' . $result->status);
} else {
throw new IcingaException('API request failed: ' . var_export($result, 1));
}
}
$this->results = $result->results; // TODO: Check if set
return $this;