Skip to content

Commit

Permalink
refactor(cmd): better error hints on 'qri connect'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arqu authored Apr 6, 2020
1 parent 855ff8f commit 734a800
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (

"github.com/qri-io/ioes"
"github.com/qri-io/qri/api"
"github.com/qri-io/qri/errors"
"github.com/qri-io/qri/lib"
"github.com/qri-io/qri/repo"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -70,7 +72,7 @@ func (o *ConnectOptions) Complete(f Factory, args []string) (err error) {
return err
}
} else if !QRIRepoInitialized(qriPath) {
return fmt.Errorf("no qri repo exists")
return errors.New(repo.ErrNoRepo, "no qri repo exists\nhave you run 'qri setup'?")
}

if err = f.Init(); err != nil {
Expand All @@ -87,7 +89,7 @@ func (o *ConnectOptions) Complete(f Factory, args []string) (err error) {
return fmt.Errorf("%s, is `qri connect` already running?", err)
}
if n == nil {
return fmt.Errorf("Cannot serve without a node (`qri connect` already running?)")
return fmt.Errorf("Cannot serve without a node (`qri connect` or Qri Desktop already running?)")
}

o.inst = f.Instance()
Expand Down
2 changes: 2 additions & 0 deletions repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var (
ErrPeerIDRequired = fmt.Errorf("repo: peerID is required")
// ErrPeernameRequired is for when a peername is missing-but-expected
ErrPeernameRequired = fmt.Errorf("repo: peername is required")
// ErrNoRepo is for when a repo is missing-but-expected
ErrNoRepo = fmt.Errorf("repo: no repo found")
// ErrNameRequired is for when a name is missing-but-expected
ErrNameRequired = fmt.Errorf("repo: name is required")
// ErrPathRequired is for when a path is missing-but-expected
Expand Down

0 comments on commit 734a800

Please sign in to comment.