From d972419cbd62c93a716f51ca8bde2579d2a1254b Mon Sep 17 00:00:00 2001 From: Shih-Hao Li Date: Tue, 6 Sep 2016 17:03:37 -0700 Subject: [PATCH] NSX|V3: Add relatedErrors in the details of ManagerError exception Change-Id: I2e6cc303ef61a61b930b51d3ce7c74d1a269662d --- vmware_nsx/nsxlib/v3/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vmware_nsx/nsxlib/v3/client.py b/vmware_nsx/nsxlib/v3/client.py index 9e07d9d84d..5610da4b91 100644 --- a/vmware_nsx/nsxlib/v3/client.py +++ b/vmware_nsx/nsxlib/v3/client.py @@ -94,8 +94,13 @@ class RESTClient(object): manager_error = ERRORS.get( result.status_code, exceptions.ManagerError) - if isinstance(result_msg, dict): - result_msg = result_msg.get('error_message', result_msg) + if isinstance(result_msg, dict) and 'error_message' in result_msg: + related_errors = [error['error_message'] for error in + result_msg.get('related_errors', [])] + result_msg = result_msg['error_message'] + if related_errors: + result_msg += " relatedErrors: %s" % ' '.join( + related_errors) raise manager_error( manager=_get_nsx_managers_from_conf(), operation=operation,