Skip to content

[improvement] Include TraceID in the message for HTTPError #21

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions conjure_python_client/_http/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ def _request(self, *args, **kwargs):
detail = e.response.json()
except ValueError:
detail = {'message': e.response.content}
detail['traceId'] = e.response.headers.get('X-B3-TraceId'),
else:
detail = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda feel like if response is None, we should just reraise the old error (e)

Copy link

Choose a reason for hiding this comment

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

I agree we should just pass along the original HttpError in that case.

I think it might be nice to wrap the HTTPError in a way that python (3.x) can understand a little better (i.e. use from future.utils import raise_from), and perhaps have a new ConjureHttpError type that has a reference to its cause as well as attributes for each of the details that can be present in an httpremoting failure response.

raise HTTPError(
'Error Name: {}. Message: {}'.format(
'Error Name: {}. TraceId {}. Message: {}.'.format(
detail.get('errorName', 'UnknownError'),
detail.get('message', 'No Message'),
detail.get('traceId', 'No TraceId'),
detail.get('message', 'No Message')
),
response=_response,
)
Expand Down