From 56254c171c530d01d6d7e47e4cbd4c6f8df3cc55 Mon Sep 17 00:00:00 2001 From: Matthew Farrellee Date: Thu, 11 Sep 2014 07:40:24 -0400 Subject: [PATCH] Sync oslo apiclient.exceptions module Changes - * Handle non-openstack errors gracefully Change-Id: I6a4fc3497aef829294d4e37850530bb455341a79 --- saharaclient/openstack/common/apiclient/exceptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saharaclient/openstack/common/apiclient/exceptions.py b/saharaclient/openstack/common/apiclient/exceptions.py index 891d79fe..9ef65075 100644 --- a/saharaclient/openstack/common/apiclient/exceptions.py +++ b/saharaclient/openstack/common/apiclient/exceptions.py @@ -447,8 +447,8 @@ def from_response(response, method, url): except ValueError: pass else: - if isinstance(body, dict): - error = list(body.values())[0] + if isinstance(body, dict) and isinstance(body.get("error"), dict): + error = body["error"] kwargs["message"] = error.get("message") kwargs["details"] = error.get("details") elif content_type.startswith("text/"):