Closed
Description
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
Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.Error 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.