8000 HttpError error_details isn't populated unless __repr__ is called first · Issue #1255 · googleapis/google-api-python-client · GitHub
[go: up one dir, main page]

Skip to content 646A
HttpError error_details isn't populated unless __repr__ is called first #1255
Closed
@jceresini

Description

@jceresini

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.type: bugError 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

    0