lib/prometheus/api_client/client.rb in prometheus-api-client-0.6.3 vs lib/prometheus/api_client/client.rb in prometheus-api-client-0.6.4
- old
+ new
@@ -102,10 +102,13 @@
# Issues a get request to the low level client, and evalueate the
# response JSON.
def run_command(command, options)
response = get(command, options)
- JSON.parse(response.body)['data']
+ body = JSON.parse(response.body)
+ raise RequestError, body['error'] if body['status'] != 'success'
+
+ body['data']
rescue StandardError => err
raise RequestError, err.message
end
# Helper function to evalueate the low level proxy option