From 19ac2ffb1f9e2895af161977d64195ba2c5a2467 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 16 Nov 2017 08:41:57 +0200 Subject: [PATCH] Add exception handling for JSON::ParserError --- libraries/api_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/api_helper.rb b/libraries/api_helper.rb index 69d49341..d521143a 100644 --- a/libraries/api_helper.rb +++ b/libraries/api_helper.rb @@ -87,7 +87,11 @@ def do_request(grafana_options, payload = nil) success: grafana_options[:success_msg], unknown_code: grafana_options[:unknown_code_msg] ) - JSON.parse(response.body) + begin + JSON.parse(response.body) + rescue JSON::ParserError + nil + end rescue BackendError nil end