Skip to content

Commit

Permalink
improve error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
mscno committed Feb 7, 2025
1 parent 7f603fb commit 91acaee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion esec.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func findPrivateKey(keyPath, envName, userSuppliedPrivateKey string) ([32]byte,
privateKeyFile, err := os.ReadFile(keyringPath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return privKey, fmt.Errorf("private key not found in environment variables, and keyring file does not exist at %q", keyringPath)
return privKey, fmt.Errorf("private key %q not found in environment variables, and keyring file does not exist at %q", keyToLookup, keyringPath)
}
return privKey, fmt.Errorf("failed to read keyring file at %q: %w", keyringPath, err)
}
Expand Down
2 changes: 1 addition & 1 deletion esec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestDecryptFile(t *testing.T) {
if err == nil {
t.Errorf("expected error, but none was received")
} else {
if !strings.Contains(err.Error(), "private key not found in environment variables, and keyring file does not exist at \"/tmp/.esec-keyring\"") {
if !strings.Contains(err.Error(), "private key \"ESEC_PRIVATE_KEY\" not found in environment variables, and keyring file does not exist at \"/tmp/.esec-keyring\"") {
t.Errorf("wanted key error, but got %v", err)
}
}
Expand Down

0 comments on commit 91acaee

Please sign in to comment.