@@ -71,7 +71,8 @@ def _load_credentials_from_file(filename):
7171 info = json .load (file_obj )
7272 except ValueError as caught_exc :
7373 new_exc = exceptions .DefaultCredentialsError (
74- 'File {} is not a valid json file.' .format (filename ))
74+ 'File {} is not a valid json file.' .format (filename ),
75+ caught_exc )
7576 six .raise_from (new_exc , caught_exc )
7677
7778 # The type key should indicate that the file is either a service account
@@ -84,9 +85,9 @@ def _load_credentials_from_file(filename):
8485 try :
8586 credentials = _cloud_sdk .load_authorized_user_credentials (info )
8687 except ValueError as caught_exc :
87- new_exc = exceptions . DefaultCredentialsError (
88- 'Failed to load authorized user credentials from {}' . format (
89- filename ) )
88+ msg = 'Failed to load authorized user credentials from {}' . format (
89+ filename )
90+ new_exc = exceptions . DefaultCredentialsError ( msg , caught_exc )
9091 six .raise_from (new_exc , caught_exc )
9192 # Authorized user credentials do not contain the project ID.
9293 return credentials , None
@@ -98,9 +99,9 @@ def _load_credentials_from_file(filename):
9899 credentials = (
99100 service_account .Credentials .from_service_account_info (info ))
100101 except ValueError as caught_exc :
101- new_exc = exceptions . DefaultCredentialsError (
102- 'Failed to load service account credentials from {}' . format (
103- filename ) )
102+ msg = 'Failed to load service account credentials from {}' . format (
103+ filename )
104+ new_exc = exceptions . DefaultCredentialsError ( msg , caught_exc )
104105 six .raise_from (new_exc , caught_exc )
105106 return credentials , info .get ('project_id' )
106107
0 commit comments