Skip to content

Add LocalProtocolError, RemoteProtocolError - #129

Merged
lovelydinosaur merged 5 commits into
masterfrom
local-and-remote-protocol-error
Aug 2, 2020
Merged

Add LocalProtocolError, RemoteProtocolError#129
lovelydinosaur merged 5 commits into
masterfrom
local-and-remote-protocol-error

Conversation

@lovelydinosaur

Copy link
Copy Markdown
Contributor

Distinguish between local and remote protocol errors, so that we can expose local errors for invalid requests, eg...

>>>importhttpcore>>>http=httpcore.SyncConnectionPool()
>>>http.request(b"GET", (b'https', b'example.org', 443, b'/'))
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/Users/tomchristie/GitHub/encode/httpcore/httpcore/_sync/connection_pool.py", line153, inrequestmethod, url, headers=headers, stream=stream, timeout=timeoutFile"/Users/tomchristie/GitHub/encode/httpcore/httpcore/_sync/connection.py", line93, inrequestreturnself.connection.request(method, url, headers, stream, timeout)
File"/Users/tomchristie/GitHub/encode/httpcore/httpcore/_sync/http11.py", line61, inrequestself._send_request(method, url, headers, timeout)
File"/Users/tomchristie/GitHub/encode/httpcore/httpcore/_sync/http11.py", line88, in_send_requestevent=h11.Request(method=method, target=target, headers=headers)
File"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line130, in__exit__self.gen.throw(type, value, traceback)
File"/Users/tomchristie/GitHub/encode/httpcore/httpcore/_exceptions.py", line12, inmap_exceptionsraiseto_exc(exc) fromNonehttpcore._exceptions.LocalProtocolError: MissingmandatoryHost: header

And...

>>>importhttpcore>>>http=httpcore.SyncConnectionPool()
>>>http.request(b"GET", (b'https', b'', 443, b'/'))
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/Users/tomchristie/GitHub/encode/httpcore/httpcore/_sync/connection_pool.py", line130, inrequestraiseLocalProtocolError("Missing hostname in URL.")
httpcore._exceptions.LocalProtocolError: MissinghostnameinURL.

@lovelydinosaurlovelydinosaur added the enhancement New feature or request label Aug 2, 2020
@lovelydinosaurlovelydinosaur added this to the 0.10.0 milestone Aug 2, 2020

@florimondmancaflorimondmanca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

I have a question - do we even need ProtocolError anymore? I don't think it's being used elsewhere in the package anymore. Edit: okay, ProtocolError is kept as the base class, that makes sense and I hadn't seen that. :-)

@lovelydinosaur
lovelydinosaur merged commit f4240b6 into masterAug 2, 2020
@lovelydinosaur
lovelydinosaur deleted the local-and-remote-protocol-error branch August 2, 2020 11:59
@lovelydinosaurlovelydinosaur mentioned this pull request Aug 3, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Development

Successfully merging this pull request may close these issues.

2 participants

@lovelydinosaur@florimondmanca