Skip to content

Commit

Permalink
Move response from AzureError to HttpResponseError (Azure#5591)
Browse files Browse the repository at this point in the history
* Move response from AzureError to HttpResponseError

* pylint fixes

* expose HttpRequest

* add BearerTokenCredentialPolicy for import
  • Loading branch information
xiangyan99 authored Jun 1, 2019
1 parent bd7206d commit 2f39cf1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions sdk/core/azure-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ from azure.core.pipeline.policies import (
HeadersPolicy,
RetryPolicy,
RedirectPolicy,
BearerTokenCredentialPolicy,
ContentDecodePolicy
)

Expand Down
1 change: 1 addition & 0 deletions sdk/core/azure-core/azure/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"Configuration",
"PipelineClient",
"HttpResponseError",
"HttpRequest",
]

try:
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/azure-core/azure/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class AzureError(Exception):

def __init__(self, message, *args, **kwargs):
self.inner_exception = kwargs.get('error')
self.response = kwargs.get('response')
self.exc_type, self.exc_value, self.exc_traceback = sys.exc_info()
self.exc_type = self.exc_type.__name__ if self.exc_type else type(self.inner_exception)
self.exc_msg = "{}, {}: {}".format(message, self.exc_type, self.exc_value) # type: ignore
Expand Down Expand Up @@ -102,6 +101,7 @@ class HttpResponseError(AzureError):

def __init__(self, message=None, response=None, **kwargs):
self.reason = None
self.response = response
if response:
self.reason = response.reason
message = "Operation returned an invalid status code '{}'".format(self.reason)
Expand All @@ -116,7 +116,7 @@ def __init__(self, message=None, response=None, **kwargs):
message = self.error.message #pylint: disable=no-member
except AttributeError:
pass
super(HttpResponseError, self).__init__(message=message, response=response, **kwargs)
super(HttpResponseError, self).__init__(message=message, **kwargs)


class DecodeError(HttpResponseError):
Expand Down

0 comments on commit 2f39cf1

Please sign in to comment.