-
Notifications
You must be signed in to change notification settings - Fork 20
[improvement] Wrap HTTPError in ConjureHTTPError with SerializableError details #22
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
Conversation
@@ -2,3 +2,4 @@ | |||
check_untyped_defs = True | |||
verbosity = 0 | |||
show_column_numbers = True | |||
ignore_missing_imports = True |
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.
mypy was having a really hard time finding the future
module, haven't been able to figure out why
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.
this seems wrong to me, I think we should fail if we can't get all of our dependencies. can we remove?
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.
Apparently mypy just isn't about validating your use of third party libraries: python/mypy#1339 (comment). The two options presented are to build our own stubs where we care or just ignore missing imports.
@@ -142,3 +131,70 @@ def init_poolmanager( | |||
ssl_context=ssl_context, | |||
**pool_kwargs | |||
) | |||
|
|||
|
|||
class ConjureHTTPError(Exception): |
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.
For naming, maybe we should be throwing a RemoteException
so it's similar to what you'd get with Java clients? This internally has a SerializableError
with these fields and the HTTP error code?
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.
Also, should this extend HttpError
? If people had previously been catching `HttpError in their code this'd now slip through right?
The tests are passing locally but failing here because they can't find the future module. Guessing this has to do with the cache only being based on |
Before this PR
HTTPError
response content was parsed hoping to findSerializableError
contents, though didn't extract all contents and relied on deprecated fields such as message. The originalHTTPError
and a message were then wrapped in a newHTTPError
and reraised.After this PR
HTTPError
is wrapped in a way (raise_from
) that is understandable to Python 3's improved traceback functionality.ConjureHTTPError
can be separately detected as such while maintaining a reference to its wrappedcause
.ConjureHTTPError
contains attributes to access fields fromSerializableError
, as well as theX-B3-TraceId
from response headers when possible.See also #21.