From fa7e52dbdaedc1a5c9f19fe9a231b021b4585dbc Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Wed, 28 Jul 2021 17:56:45 +0300 Subject: [PATCH] add explicit error msg if repo dir does not exist --- cli/util/api.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cli/util/api.go b/cli/util/api.go index 37df41a87..207283fd1 100644 --- a/cli/util/api.go +++ b/cli/util/api.go @@ -2,6 +2,7 @@ package cliutil import ( "context" + "errors" "fmt" "net/http" "net/url" @@ -142,6 +143,15 @@ func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) { return APIInfo{}, xerrors.Errorf("could not open repo at path: %s; %w", p, err) } + exists, err := r.Exists() + if err != nil { + return APIInfo{}, xerrors.Errorf("repo.Exists returned an error: %w", err) + } + + if !exists { + return APIInfo{}, errors.New("repo directory does not exist. Make sure your configuration is correct") + } + ma, err := r.APIEndpoint() if err != nil { return APIInfo{}, xerrors.Errorf("could not get api endpoint: %w", err)