Skip to content
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

add underlying cause for TransportError #1441

Open
gchux opened this issue Dec 15, 2023 · 1 comment
Open

add underlying cause for TransportError #1441

gchux opened this issue Dec 15, 2023 · 1 comment
Labels
help wanted We'd love to have community involvement on this issue. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@gchux
Copy link

gchux commented Dec 15, 2023

Is it possible to save a reference to the last exception thrown at:

response = request(url=url, method="GET", headers=headers_to_use)

and use it to build a more meaningful error message? at:

raise exceptions.TransportError(
"Failed to retrieve {} from the Google Compute Engine "
"metadata service. Compute Engine Metadata server unavailable".format(url)
)

that way the underlying reason for the TransportError would be available even if DEBUG logging level is not enabled.

@clundin25 clundin25 added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Dec 15, 2023
@clundin25
Copy link
Contributor

Should be a small and easy fix. Just add a variable store the last seen exception, and inherit it using the from syntax.

https://docs.python.org/3/tutorial/errors.html#exception-chaining

@clundin25 clundin25 added the help wanted We'd love to have community involvement on this issue. label Dec 15, 2023
gchux added a commit to gchux/google-auth-library-python that referenced this issue Dec 21, 2023
Simplifying thoubleshooting by capturing last seen exception
to set is as the direct cause of the `exceptions.TransportError`
gchux added a commit to gchux/google-auth-library-python that referenced this issue Dec 21, 2023
Simplifying thoubleshooting by capturing last seen exception
to set is as the direct cause of the `exceptions.TransportError`
gchux added a commit to gchux/google-auth-library-python that referenced this issue Dec 21, 2023
Simplifying thoubleshooting by capturing last seen exception
to set is as the direct cause of the `exceptions.TransportError`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We'd love to have community involvement on this issue. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants