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')
diff --git a/google/auth/compute_engine/credentials.py b/google/auth/compute_engine/credentials.py
index cbc7cf4..3841df2 100644
--- a/google/auth/compute_engine/credentials.py
+++ b/google/auth/compute_engine/credentials.py
@@ -92,7 +92,7 @@
request,
service_account=self._service_account_email)
except exceptions.TransportError as caught_exc:
- new_exc = exceptions.RefreshError()
+ new_exc = exceptions.RefreshError(caught_exc)
six.raise_from(new_exc, caught_exc)
@property
diff --git a/google/auth/transport/_http_client.py b/google/auth/transport/_http_client.py
index 35b1005..08b1ab6 100644
--- a/google/auth/transport/_http_client.py
+++ b/google/auth/transport/_http_client.py
@@ -106,7 +106,7 @@
return Response(response)
except (http_client.HTTPException, socket.error) as caught_exc:
- new_exc = exceptions.TransportError()
+ new_exc = exceptions.TransportError(caught_exc)
six.raise_from(new_exc, caught_exc)
finally:
diff --git a/google/auth/transport/requests.py b/google/auth/transport/requests.py
index 66ff0d3..a49d3de 100644
--- a/google/auth/transport/requests.py
+++ b/google/auth/transport/requests.py
@@ -118,7 +118,7 @@
**kwargs)
return _Response(response)
except requests.exceptions.RequestException as caught_exc:
- new_exc = exceptions.TransportError()
+ new_exc = exceptions.TransportError(caught_exc)
six.raise_from(new_exc, caught_exc)
diff --git a/google/auth/transport/urllib3.py b/google/auth/transport/urllib3.py
index ec20fb6..37eb317 100644
--- a/google/auth/transport/urllib3.py
+++ b/google/auth/transport/urllib3.py
@@ -133,7 +133,7 @@
method, url, body=body, headers=headers, **kwargs)
return _Response(response)
except urllib3.exceptions.HTTPError as caught_exc:
- new_exc = exceptions.TransportError()
+ new_exc = exceptions.TransportError(caught_exc)
six.raise_from(new_exc, caught_exc)