Skip to content
Permalink
Browse files

add humanized error when the stack (app) does not exist

  • Loading branch information...
tj committed Feb 24, 2018
1 parent c14c480 commit cc561d89d9e4ad89c26134b01f17781a81ba5a1b
Showing with 17 additions and 2 deletions.
  1. +5 −2 cmd/up/main.go
  2. +12 −0 internal/util/util.go
@@ -4,7 +4,6 @@ import (
"errors"
"os"
"runtime"
"strings"

"github.com/stripe/stripe-go"
"github.com/tj/go/env"
@@ -47,7 +46,11 @@ func main() {

term.ShowCursor()

if strings.Contains(err.Error(), "NoCredentialProviders") {
if util.IsNotFound(err) {
util.Fatal(errors.New("Cannot find application, make sure you deployed with `$ up`."))
}

if util.IsNoCredentials(err) {
util.Fatal(errors.New("Cannot find credentials, visit https://up.docs.apex.sh/#aws_credentials for help."))
}

@@ -166,6 +166,18 @@ func IsThrottled(err error) bool {
}
}

// IsNoCredentials returns true if err is not nil and represents missing credentials.
func IsNoCredentials(err error) bool {
switch {
case err == nil:
return false
case strings.Contains(err.Error(), "NoCredentialProviders"):
return true
default:
return false
}
}

// Env returns a slice from environment variable map.
func Env(m map[string]string) (env []string) {
for k, v := range m {

0 comments on commit cc561d8

Please sign in to comment.
You can’t perform that action at this time.