Throws InfluxDBClientError if there was an error after quering

This commit is contained in:
danibrutal
2015-06-18 15:05:04 +02:00
parent 033d593d51
commit d55af50722
2 changed files with 28 additions and 0 deletions
+7
View File
@@ -73,11 +73,18 @@ class ResultSet
* results is an array of objects, one for each query,
* each containing the keys for a series
*
* @throws InfluxDBClientError
*
* @return array $series
*/
public function getSeries()
{
$pickSeries = function ($object) {
if (isset($object['error'])) {
throw new InfluxDBClientError($object['error']);
}
return $object['series'];
};
+21
View File
@@ -40,6 +40,27 @@ EOD;
new ResultSet($errorResult);
}
/**
* Throws Exception if something went wrong with influxDB after processing the query
* @expectedException \Leaseweb\InfluxDB\InfluxDBClientError
*/
public function testThrowsInfluxDBExceptionIfAnyErrorInSeries()
{
$errorResult = <<<EOD
{
"results": [
{
"series": [],
"error": "There was an error after querying"
}
]
}
EOD;
$rs = new ResultSet($errorResult);
$rs->getSeries();
}
/**
* We can get points from measurement
*/