Parse exception from SDK

Some exceptions from SDK are not in stardard json format,
this patch parse it to json.

Change-Id: If39704f24b084cd1f6aaccd3c951636a53f3ddc1
Partial-Bug: #1472557
This commit is contained in:
Haiwei Xu
2015-07-22 10:52:33 +09:00
parent d355c0b65a
commit 72da3597e4

View File

@@ -231,7 +231,12 @@ def parse_exception(exc):
:param details: details of the exception.
'''
if isinstance(exc, sdkexc.HttpException):
record = jsonutils.loads(exc.details)
record = {
'error': {
'code': exc.status_code,
'message': exc.details,
}
}
elif isinstance(exc, reqexc.RequestException):
# Exceptions that are not captured by SDK
code = exc.message[1].errno