Adding back "wrapped" exceptions in Refresh/Transport errors.
diff --git a/google/auth/_default.py b/google/auth/_default.py
index 06f52bb..5410a4c 100644
--- a/google/auth/_default.py
+++ b/google/auth/_default.py
@@ -71,7 +71,8 @@
info = json.load(file_obj)
except ValueError as caught_exc:
new_exc = exceptions.DefaultCredentialsError(
- 'File {} is not a valid json file.'.format(filename))
+ 'File {} is not a valid json file.'.format(filename),
+ caught_exc)
six.raise_from(new_exc, caught_exc)
# The type key should indicate that the file is either a service account
@@ -84,9 +85,9 @@
try:
credentials = _cloud_sdk.load_authorized_user_credentials(info)
except ValueError as caught_exc:
- new_exc = exceptions.DefaultCredentialsError(
- 'Failed to load authorized user credentials from {}'.format(
- filename))
+ msg = 'Failed to load authorized user credentials from {}'.format(
+ filename)
+ new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
six.raise_from(new_exc, caught_exc)
# Authorized user credentials do not contain the project ID.
return credentials, None
@@ -98,9 +99,9 @@
credentials = (
service_account.Credentials.from_service_account_info(info))
except ValueError as caught_exc:
- new_exc = exceptions.DefaultCredentialsError(
- 'Failed to load service account credentials from {}'.format(
- filename))
+ msg = 'Failed to load service account credentials from {}'.format(
+ filename)
+ new_exc = exceptions.DefaultCredentialsError(msg, caught_exc)
six.raise_from(new_exc, caught_exc)
return credentials, info.get('project_id')