Restore compat with Autorest TestServer

This commit is contained in:
Laurent Mazuel 2017-09-28 16:31:45 -07:00
Родитель 8a0ef97f7e
Коммит 9134ffc997
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -134,13 +134,17 @@ class HttpOperationError(ClientException):
self.error = deserialize(resp_type, response)
if self.error is None:
self.error = deserialize.dependencies[resp_type]()
# ARM uses OData v4
# ARM uses OData v4, try that by default
# http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html#_Toc372793091
# Code and Message are REQUIRED
self.message = "({}) {}".format(
self.error.error.code,
self.error.error.message
)
try:
self.message = "({}) {}".format(
self.error.error.code,
self.error.error.message
)
except AttributeError:
# Try the default for Autorest if not available (compat)
self.message = self.error.message
except (DeserializationError, AttributeError, KeyError):
pass