HC Test: exception handling for restconf GET operation 86/9286/3
authorselias <samelias@cisco.com>
Wed, 8 Nov 2017 13:42:09 +0000 (14:42 +0100)
committerTibor Frank <tifrank@cisco.com>
Wed, 8 Nov 2017 14:30:26 +0000 (14:30 +0000)
When response to GET is 404, json loads() may fail with ValueError.

Change-Id: If627574bb7909a105d13381a2b89445f527ccb7b
Signed-off-by: selias <samelias@cisco.com>
resources/libraries/python/honeycomb/HoneycombUtil.py

index b7338d3..76bb5b3 100644 (file)
@@ -302,7 +302,14 @@ class HoneycombUtil(object):
         base_path = HoneycombUtil.read_path_from_url_file(url_file)
         path = base_path + path
         status_code, resp = HTTPRequest.get(node, path)
-        return status_code, loads(resp)
+
+        try:
+            data = loads(resp)
+        except ValueError:
+            logger.debug("Failed to deserialize JSON data.")
+            data = None
+
+        return status_code, data
 
     @staticmethod
     def put_honeycomb_data(node, url_file, data, path="",

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.