Skip to content

Commit

Permalink
google/externalaccount: return error messages from file cred opening
Browse files Browse the repository at this point in the history
subjectToken function now return error messages when failing to open file credentials.

This will allow distinguishing between file not found and other errors.
  • Loading branch information
kaovilai committed Oct 22, 2024
1 parent 3e64809 commit e72b1dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion google/externalaccount/filecredsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (cs fileCredentialSource) credentialSourceType() string {
func (cs fileCredentialSource) subjectToken() (string, error) {
tokenFile, err := os.Open(cs.File)
if err != nil {
return "", fmt.Errorf("oauth2/google/externalaccount: failed to open credential file %q", cs.File)
return "", fmt.Errorf("oauth2/google/externalaccount: failed to open credential file %q due to %v", cs.File, err)
}
defer tokenFile.Close()
tokenBytes, err := ioutil.ReadAll(io.LimitReader(tokenFile, 1<<20))
Expand Down

0 comments on commit e72b1dc

Please sign in to comment.