From f10ee539c8dcfd08083ee8f631c8dd39e7d62044 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 18 Mar 2016 13:49:42 +0100 Subject: [PATCH] RestApiResponse: throw error on error result --- library/Director/Core/RestApiResponse.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/Director/Core/RestApiResponse.php b/library/Director/Core/RestApiResponse.php index 3145f1d3..253fed1f 100644 --- a/library/Director/Core/RestApiResponse.php +++ b/library/Director/Core/RestApiResponse.php @@ -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;