Skip to content

Commit

Permalink
Better error for when exec doesn't find any credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
lox committed Sep 3, 2015
1 parent 598b707 commit 2e90ce2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os/exec"

"github.com/99designs/aws-vault/keyring"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
)

Expand All @@ -24,7 +25,11 @@ func ExecCommand(ui Ui, input ExecCommandInput) {
creds := credentials.NewCredentials(provider)
val, err := creds.Get()
if err != nil {
ui.Error.Fatal(err)
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoCredentialProviders" {
ui.Error.Fatalf("No credentials found for profile %q", input.Profile)
} else {
ui.Error.Fatal(err)
}
}

env := append(os.Environ(),
Expand Down

0 comments on commit 2e90ce2

Please sign in to comment.