From 92b77048dc3879c7572a2fe64eb199e6d72bdce0 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 12 May 2014 13:51:55 -0500 Subject: [PATCH] Handle ValueError during json.loads of json data from build --- library/cloud/docker_image | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/cloud/docker_image b/library/cloud/docker_image index ce46d615c0a..2ab764c68ad 100644 --- a/library/cloud/docker_image +++ b/library/cloud/docker_image @@ -140,7 +140,10 @@ class DockerImageManager: if not chunk: continue - chunk_json = json.loads(chunk) + try: + chunk_json = json.loads(chunk) + except ValueError: + continue if 'error' in chunk_json: self.error_msg = chunk_json['error'] @@ -153,6 +156,12 @@ class DockerImageManager: if match: image_id = match.group(1) + # Just in case we skipped evaluating the JSON returned from build + # during every iteration, add an error if the image_id was never + # populated + if not image_id: + self.error_msg = 'Unknown error encountered' + return image_id def has_changed(self):