mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-03 00:11:49 +02:00
Throws InfluxDBClientError if there was an error after quering
This commit is contained in:
@@ -73,11 +73,18 @@ class ResultSet
|
|||||||
* results is an array of objects, one for each query,
|
* results is an array of objects, one for each query,
|
||||||
* each containing the keys for a series
|
* each containing the keys for a series
|
||||||
*
|
*
|
||||||
|
* @throws InfluxDBClientError
|
||||||
|
*
|
||||||
* @return array $series
|
* @return array $series
|
||||||
*/
|
*/
|
||||||
public function getSeries()
|
public function getSeries()
|
||||||
{
|
{
|
||||||
$pickSeries = function ($object) {
|
$pickSeries = function ($object) {
|
||||||
|
|
||||||
|
if (isset($object['error'])) {
|
||||||
|
throw new InfluxDBClientError($object['error']);
|
||||||
|
}
|
||||||
|
|
||||||
return $object['series'];
|
return $object['series'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,27 @@ EOD;
|
|||||||
new ResultSet($errorResult);
|
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
|
* We can get points from measurement
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user