From 29c4983fdc1cea0ed859db63f71e014c2b765fe3 Mon Sep 17 00:00:00 2001 From: Azeem Shaikh Date: Sat, 8 May 2021 16:28:59 -0700 Subject: [PATCH] Return error instead of log.fatal. (#421) Co-authored-by: Azeem Shaikh --- repos/repo_url.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repos/repo_url.go b/repos/repo_url.go index b49116cb..4915fd4f 100644 --- a/repos/repo_url.go +++ b/repos/repo_url.go @@ -17,7 +17,6 @@ package repos import ( "errors" "fmt" - "log" "net/url" "strings" ) @@ -25,6 +24,7 @@ import ( var ( ErrorUnsupportedHost = errors.New("unsupported host") ErrorInvalidGithubURL = errors.New("invalid GitHub repo URL") + ErrorInvalidURL = errors.New("invalid repo flag") ) type RepoURL struct { @@ -58,7 +58,7 @@ func (r *RepoURL) Set(s string) error { const splitLen = 2 split := strings.SplitN(strings.Trim(u.Path, "/"), "/", splitLen) if len(split) != splitLen { - log.Fatalf("invalid repo flag: [%s], pass the full repository URL", s) + return fmt.Errorf("%w: [%s], pass the full repository URL", ErrorInvalidURL, s) } r.Host, r.Owner, r.Repo = u.Host, split[0], split[1]