Skip to content

Commit

Permalink
Merge pull request #11 from convox/fix-login-error
Browse files Browse the repository at this point in the history
report actual error on login
  • Loading branch information
csquared committed Sep 15, 2015
2 parents 7074103 + da9efaa commit e509525
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions cmd/convox/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -38,7 +37,8 @@ func init() {
home, err := homedir.Dir()

if err != nil {
log.Fatal(err)
stdcli.Error(err)
return
}

ConfigRoot = filepath.Join(home, ".convox")
Expand All @@ -50,14 +50,16 @@ func init() {
stat, err := os.Stat(ConfigRoot)

if err != nil && !os.IsNotExist(err) {
log.Fatal(err)
stdcli.Error(err)
return
}

if stat != nil && !stat.IsDir() {
err := upgradeConfig()

if err != nil {
log.Fatal(err)
stdcli.Error(err)
return
}
}
}
Expand Down Expand Up @@ -105,7 +107,11 @@ func cmdLogin(c *cli.Context) {
_, err = cl.GetApps()

if err != nil {
stdcli.Error(fmt.Errorf("invalid login"))
if strings.Contains(err.Error(), "401") {
stdcli.Error(fmt.Errorf("invalid login"))
} else {
stdcli.Error(fmt.Errorf("could not contact host"))
}
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/convox/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestInvalidLogin(t *testing.T) {
Command: "convox login --password foobar BAD",
Env: map[string]string{"CONVOX_CONFIG": temp},
Exit: 1,
Stderr: "ERROR: invalid login\n",
Stderr: "ERROR: could not contact host\n",
},
)
}
Expand Down

0 comments on commit e509525

Please sign in to comment.