The request did not reach the provider (or could not be built):
its method and url (without its URL parameters), and, when made
with from_http_client_error, the HttpClientError as cause,
kept as it is (its text is not redacted).
Attributes#
| Attribute | Type | Description |
|---|---|---|
reason | Literal['TransportError', 'EncodeError', 'InvalidUrlError'] | |
method | str | |
url | str | |
description | str | None = None | |
cause | object = None | |
is_retryable | bool | |
message | str |
Functions#
__init__#
__init__(reason, method, url, description=None, cause=None) -> None| Parameter | Type | Description |
|---|---|---|
reason | Literal['TransportError', 'EncodeError', 'InvalidUrlError'] | |
method | str | |
url | str | |
description | str | None = None | |
cause | object = None |
from_request_error#
from_request_error(error) -> NetworkErrorThe error for a request reason of an HttpClientError.
| Parameter | Type | Description |
|---|---|---|
error | http_error.RequestError |
Returns NetworkError
@staticmethod
def from_request_error(error: http_error.RequestError) -> NetworkError:
"""The error for a request reason of an ``HttpClientError``."""
return NetworkError(
reason=error.tag,
method=error.request.method,
url=error.request.url,
description=error.description,
)from_http_client_error#
from_http_client_error(error) -> NetworkErrorThe error for an HttpClientError whose reason is a request
reason, keeping error as cause. Raises TypeError for a
response reason (Effect's type admits only request reasons).
| Parameter | Type | Description |
|---|---|---|
error | http_error.HttpClientError |
Returns NetworkError
@staticmethod
def from_http_client_error(error: http_error.HttpClientError) -> NetworkError:
"""The error for an ``HttpClientError`` whose reason is a request
reason, keeping ``error`` as ``cause``. Raises ``TypeError`` for a
response reason (Effect's type admits only request reasons)."""
reason = error.reason
match reason:
case (
http_error.TransportError()
| http_error.EncodeError()
| http_error.InvalidUrlError()
):
return NetworkError(
reason=reason.tag,
method=reason.request.method,
url=reason.request.url,
description=reason.description,
cause=error,
)
case _:
raise TypeError(f"{reason.tag} is not a request error")