|
@@ -3,6 +3,7 @@
|
|
|
namespace StatsDBundle\Services;
|
|
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
+use \Exception;
|
|
|
|
|
|
/**
|
|
|
* Read statistics to the statsD
|
|
@@ -36,7 +37,7 @@ class EndpointMysql
|
|
|
* query = [last|query|search]
|
|
|
*/
|
|
|
|
|
|
- public function get($json, $method = "query")
|
|
|
+ public function get($json, $method = "query", $exception = false)
|
|
|
{
|
|
|
if(is_null($this->location)) return array();
|
|
|
|
|
@@ -53,9 +54,14 @@ class EndpointMysql
|
|
|
|
|
|
$result = curl_exec($ch);
|
|
|
if (curl_errno($ch)) {
|
|
|
- echo 'Error:' . curl_error($ch);
|
|
|
+ if($exception) {
|
|
|
+ curl_close($ch);
|
|
|
+ throw new Exception(curl_error($ch));
|
|
|
+ } else {
|
|
|
+ echo 'Error:' . curl_error($ch);
|
|
|
+ }
|
|
|
}
|
|
|
- curl_close ($ch);
|
|
|
+ curl_close($ch);
|
|
|
|
|
|
$data = json_decode($result,true);
|
|
|
if(is_array($data))
|