xL iO!dZddlmZddlZddlZej rddlmZmZgdZ Gdde Z Gd d e Z Gd d e Z Gd de ZGddeZGddeZGddeZGddeZGdde ZGddeZGddeZGddeZGdd eZGd!d"e ZGd#d$e ZGd%d&e ZGd'd(eZGd)d*eZGd+d,e ZGd-d.e ZGd/d0e ZGd1d2e Z Gd3d4e Z!Gd5d6e"Z#Gd7d8e#Z$Gd9d:e#Z%Gd;de#Z'ejP d@ dAd?Z)y)Bul Our exception hierarchy: * HTTPError x RequestError + TransportError - TimeoutException · ConnectTimeout · ReadTimeout · WriteTimeout · PoolTimeout - NetworkError · ConnectError · ReadError · WriteError · CloseError - ProtocolError · LocalProtocolError · RemoteProtocolError - ProxyError - UnsupportedProtocol + DecodingError + TooManyRedirects x HTTPStatusError * InvalidURL * CookieConflict * StreamError x StreamConsumed x StreamClosed x ResponseNotRead x RequestNotRead ) annotationsN)RequestResponse) CloseError ConnectErrorConnectTimeoutCookieConflict DecodingError HTTPErrorHTTPStatusError InvalidURLLocalProtocolError NetworkError PoolTimeout ProtocolError ProxyError ReadError ReadTimeoutRemoteProtocolError RequestErrorRequestNotReadResponseNotRead StreamClosedStreamConsumed StreamErrorTimeoutExceptionTooManyRedirectsTransportErrorUnsupportedProtocol WriteError WriteTimeoutc\eZdZdZdfd ZeddZejddZxZS)r a Base class for `RequestError` and `HTTPStatusError`. Useful for `try...except` blocks when issuing a request, and then calling `.raise_for_status()`. For example: ``` try: response = httpx.get("https://www.example.com") response.raise_for_status() except httpx.HTTPError as exc: print(f"HTTP Exception for {exc.request.url} - {exc}") ``` c2t||d|_yNsuper__init___requestselfmessage __class__s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/httpx/_exceptions.pyr(zHTTPError.__init__\s !(, cH|j td|jS)Nz'The .request property has not been set.)r) RuntimeError)r+s r.requestzHTTPError.request`s" == HI I}}r/c||_yr%)r))r+r2s r.r2zHTTPError.requestfs  r/r,strreturnNone)r6r)r2rr6r7) __name__ __module__ __qualname____doc__r(propertyr2setter __classcell__r-s@r.r r Js9"-  ^^  r/r c*eZdZdZdddfdZxZS)rzS Base class for all exceptions that may occur when issuing a `.request()`. N)r2c2t||||_yr%r&)r+r,r2r-s r.r(zRequestError.__init__ps !  r/)r,r5r2Request | Noner6r7r8r9r:r;r(r>r?s@r.rrksCG  r/rceZdZdZy)rzU Base class for all exceptions that occur at the level of the Transport API. Nr8r9r:r;r/r.rr{r/rceZdZdZy)rzM The base class for timeout errors. An operation has timed out. NrErFr/r.rrr/rceZdZdZy)r z1 Timed out while connecting to the host. NrErFr/r.r r rGr/r ceZdZdZy)rz7 Timed out while receiving data from the host. NrErFr/r.rrrGr/rceZdZdZy)r"z3 Timed out while sending data to the host. NrErFr/r.r"r"rGr/r"ceZdZdZy)rzB Timed out waiting to acquire a connection from the pool. NrErFr/r.rrrGr/rceZdZdZy)rzo The base class for network-related errors. An error occurred while interacting with the network. NrErFr/r.rrrIr/rceZdZdZy)rz2 Failed to receive data from the network. NrErFr/r.rrrGr/rceZdZdZy)r!z2 Failed to send data through the network. NrErFr/r.r!r!rGr/r!ceZdZdZy)rz+ Failed to establish a connection. NrErFr/r.rrrGr/rceZdZdZy)rz' Failed to close a connection. NrErFr/r.rrrGr/rceZdZdZy)rzB An error occurred while establishing a proxy connection. NrErFr/r.rrrGr/rceZdZdZy)r z Attempted to make a request to an unsupported protocol. For example issuing a request to `ftp://www.example.com`. NrErFr/r.r r rIr/r ceZdZdZy)rz$ The protocol was violated. NrErFr/r.rrrGr/rceZdZdZy)rz A protocol was violated by the client. For example if the user instantiated a `Request` instance explicitly, failed to include the mandatory `Host:` header, and then issued it directly using `client.send()`. NrErFr/r.rrsr/rceZdZdZy)rz^ The protocol was violated by the server. For example, returning malformed HTTP. NrErFr/r.rrrIr/rceZdZdZy)r zG Decoding of the response failed, due to a malformed encoding. NrErFr/r.r r rGr/r ceZdZdZy)rz Too many redirects. NrErFr/r.rrrGr/rc$eZdZdZdfd ZxZS)r z| The response had an error HTTP status of 4xx or 5xx. May be raised when calling `response.raise_for_status()` c@t||||_||_yr%)r'r(r2response)r+r,r2r\r-s r.r(zHTTPStatusError.__init__ s !   r/)r,r5r2rr\rr6r7rCr?s@r.r r s !!r/r c$eZdZdZdfd ZxZS)rz7 URL is improperly formed or cannot be parsed. c$t||yr%r'r(r*s r.r(zInvalidURL.__init__ !r/r4rCr?s@r.rrs""r/rc$eZdZdZdfd ZxZS)r z Attempted to lookup a cookie by name, but multiple cookies existed. Can occur when calling `response.cookies.get(...)`. c$t||yr%r_r*s r.r(zCookieConflict.__init__r`r/r4rCr?s@r.r r s ""r/r c$eZdZdZdfd ZxZS)rz The base class for stream exceptions. The developer made an error in accessing the request stream in an invalid way. c$t||yr%r_r*s r.r(zStreamError.__init__1r`r/r4rCr?s@r.rr)s""r/rc$eZdZdZdfd ZxZS)rz] Attempted to read or stream content, but the content has already been streamed. c(d}t||y)Na]Attempted to read or stream some content, but the content has already been streamed. For requests, this could be due to passing a generator as request content, and then receiving a redirect response or a secondary request as part of an authentication flow.For responses, this could be due to attempting to stream the response content more than once.r_r*s r.r(zStreamConsumed.__init__;s &  !r/r6r7rCr?s@r.rr5s " "r/rc$eZdZdZdfd ZxZS)rz\ Attempted to read or stream response content, but the request has been closed. c(d}t||y)NzDAttempted to read or stream content, but the stream has been closed.r_r*s r.r(zStreamClosed.__init__Ms U  !r/rgrCr?s@r.rrGs ""r/rc$eZdZdZdfd ZxZS)rzY Attempted to access streaming response content, without having called `read()`. c(d}t||y)NzOAttempted to access streaming response content, without having called `read()`.r_r*s r.r(zResponseNotRead.__init__Y /  !r/rgrCr?s@r.rrT""r/rc$eZdZdZdfd ZxZS)rzX Attempted to access streaming request content, without having called `read()`. c(d}t||y)NzNAttempted to access streaming request content, without having called `read()`.r_r*s r.r(zRequestNotRead.__init__frlr/rgrCr?s@r.rrarmr/rc#NK dy#t$r}|||_|d}~wwxYww)z A context manager that can be used to attach the given request context to any `RequestError` exceptions that are raised within the block. N)rr2)r2excs r.request_contextrrns/   !CK s% % " "%r%)r2rBr6ztyping.Iterator[None])*r; __future__r contextlibtyping TYPE_CHECKING_modelsrr__all__ Exceptionr rrrr rr"rrrr!rrrr rrrr rr rr r1rrrrrcontextmanagerrrrFr/r.r{sB#  * @  B  9  \~% " # ">   <  .N -L | !i !"""Y"" ", ""["$ "; " "k " "[ " "     r/