-
Notifications
You must be signed in to change notification settings - Fork 3.2k
raise decode error instead of ContentDecodingError #19433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7951899
936c5a2
d354653
84bc38d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,14 +29,15 @@ | |
| import urllib3 # type: ignore | ||
| from urllib3.util.retry import Retry # type: ignore | ||
| from urllib3.exceptions import ( | ||
| DecodeError, ReadTimeoutError, ProtocolError | ||
| DecodeError as CoreDecodeError, ReadTimeoutError, ProtocolError | ||
| ) | ||
| import requests | ||
|
|
||
| from azure.core.configuration import ConnectionConfiguration | ||
| from azure.core.exceptions import ( | ||
| ServiceRequestError, | ||
| ServiceResponseError | ||
| ServiceResponseError, | ||
| DecodeError | ||
| ) | ||
| from . import HttpRequest # pylint: disable=unused-import | ||
|
|
||
|
|
@@ -59,11 +60,11 @@ def _read_raw_stream(response, chunk_size=1): | |
| for chunk in response.raw.stream(chunk_size, decode_content=False): | ||
| yield chunk | ||
| except ProtocolError as e: | ||
| raise requests.exceptions.ChunkedEncodingError(e) | ||
| except DecodeError as e: | ||
| raise requests.exceptions.ContentDecodingError(e) | ||
| raise ServiceResponseError(e, error=e) | ||
| except CoreDecodeError as e: | ||
| raise DecodeError(e, error=e) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This scenario is being correctly handled in the other transports?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently different transport raises different type of error. (That's the reason we need this change). We want to uniform the errors so user can catch all by using except AzureError. |
||
| except ReadTimeoutError as e: | ||
| raise requests.exceptions.ConnectionError(e) | ||
| raise ServiceRequestError(e, error=e) | ||
| else: | ||
| # Standard file-like object. | ||
| while True: | ||
|
|
@@ -161,6 +162,8 @@ def __next__(self): | |
| raise StopIteration() | ||
| except requests.exceptions.StreamConsumedError: | ||
| raise | ||
| except requests.exceptions.ContentDecodingError as err: | ||
| raise DecodeError(err, error=err) | ||
| except Exception as err: | ||
| _LOGGER.warning("Unable to stream download: %s", err) | ||
| internal_response.close() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we okay with this breaking change because no one should have written code to explicitly handle this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Checked with @johanste and he agreed this was an acceptable breaking change.