From 54e4d4821a615270353de338657f36bdae312044 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 16 Nov 2017 08:13:15 +0200 Subject: [PATCH] Add exception handling for JSON::ParserError --- libraries/organization_api.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/organization_api.rb b/libraries/organization_api.rb index 0a3d0eae..1a2cb42f 100644 --- a/libraries/organization_api.rb +++ b/libraries/organization_api.rb @@ -199,7 +199,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