Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

HttpError error_details isn't populated unless __repr__ is called first #1255

Copy link
Copy link
Closed
@jceresini

Description

@jceresini
Issue body actions

I was trying to handle an HttpError by looking at the contents of the error_details attribute. I noticed the attribute is a null-string unless I trigger the __repr__ function first. For example, this does not work as the error_details is always "". I made a simple test that demonstrates the error:

from googleapiclient import discovery, errors

client = discovery.build(
    "discovery", "v1"
)

req = client.apis().getRest(api='fake_api', version='v1')

try:
    resp = req.execute()
except errors.HttpError as err:
    print(f'Error details are currently: "{err.error_details}"')
    print(f'Exception string representation is: "{err}"')
    print(f'Error details are currently: "{err.error_details}"')

The output of the above code:

Error details are currently: ""
Exception string representation is: "<HttpError 404 when requesting https://www.googleapis.com/discovery/v1/apis/fake_api/v1/rest?alt=json returned "Requested entity was not found.". Details: "Requested entity was not found.">"
Error details are currently: "Requested entity was not found."

I tested and the behavior is the same on both google-api-python-client-1.12.8 and google-api-python-client-2.0.2

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.