google-auth-library-python icon indicating copy to clipboard operation
google-auth-library-python copied to clipboard

add underlying cause for `TransportError`

Open gchux opened this issue 1 year ago • 1 comments

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

https://github.com/googleapis/google-auth-library-python/blob/0afc61a3a9c3d5035c913ad4a7568e8a888e2ec9/google/auth/compute_engine/_metadata.py#L204

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

https://github.com/googleapis/google-auth-library-python/blob/0afc61a3a9c3d5035c913ad4a7568e8a888e2ec9/google/auth/compute_engine/_metadata.py#L217-L220

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

gchux avatar Dec 15 '23 18:12 gchux

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 avatar Dec 15 '23 22:12 clundin25