feat: improved error messages
This commit is contained in:
parent
e2e508adc5
commit
1c2be88daa
4 changed files with 11 additions and 11 deletions
|
|
@ -76,7 +76,7 @@ func pullRepository(repoName string, repoDestination string) {
|
|||
remoteCmd := exec.Command("git", "-C", repoDestination, "remote", "show")
|
||||
remoteOutput, err := remoteCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("finding remote: %v", err)
|
||||
return "", fmt.Errorf("finding remote: %v\n", err)
|
||||
}
|
||||
|
||||
remote := strings.Split(strings.TrimSpace(string(remoteOutput)), "\n")[0]
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
|||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("creating request: %v", err)
|
||||
return nil, fmt.Errorf("creating request: %v\n", err)
|
||||
}
|
||||
|
||||
req.Header.Set("PRIVATE-TOKEN", gitlabToken)
|
||||
|
|
@ -37,21 +37,21 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
|||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("making request: %v", err)
|
||||
return nil, fmt.Errorf("making request: %v\n", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("API request failed with status: %d", resp.StatusCode)
|
||||
return nil, fmt.Errorf("API request failed with status: %d\n", resp.StatusCode)
|
||||
}
|
||||
|
||||
var repositories []Repository
|
||||
if err := json.NewDecoder(resp.Body).Decode(&repositories); err != nil {
|
||||
return nil, fmt.Errorf("decoding response: %v", err)
|
||||
return nil, fmt.Errorf("decoding response: %v\n", err)
|
||||
}
|
||||
|
||||
if len(repositories) < 1 {
|
||||
return repositories, fmt.Errorf("no repositories found")
|
||||
return repositories, fmt.Errorf("no repositories found\n")
|
||||
}
|
||||
|
||||
return repositories, nil
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func manageArguments() {
|
|||
gitlabToken = envToken
|
||||
default:
|
||||
flag.Usage()
|
||||
log.Printf("fatal: config; gitlab api token not found")
|
||||
log.Printf("fatal: config; gitlab api token not found\n")
|
||||
}
|
||||
|
||||
// manage gitlab url option
|
||||
|
|
@ -38,7 +38,7 @@ func manageArguments() {
|
|||
gitlabHost = envHost
|
||||
default:
|
||||
flag.Usage()
|
||||
log.Fatalf("fatal: config; gitlab host not found")
|
||||
log.Fatalf("fatal: config; gitlab host not found\n")
|
||||
}
|
||||
|
||||
// manage destination option
|
||||
|
|
@ -47,7 +47,7 @@ func manageArguments() {
|
|||
repoDestinationPre = envRepoDest
|
||||
default:
|
||||
flag.Usage()
|
||||
log.Fatalf("fatal: config; destination not found")
|
||||
log.Fatalf("fatal: config; destination not found\n")
|
||||
}
|
||||
|
||||
// add slash 🎩🎸 if not provided
|
||||
|
|
@ -72,6 +72,6 @@ func manageArguments() {
|
|||
|
||||
default:
|
||||
flag.Usage()
|
||||
log.Fatalf("fatal: config; no or wrong archive option found")
|
||||
log.Fatalf("fatal: config; no or wrong archive option found\n")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func progressBar(repositories []Repository) {
|
|||
|
||||
func progressBarAdd(amount int) {
|
||||
if err := bar.Add(amount); err != nil {
|
||||
log.Printf("Progress bar update error: %v", err)
|
||||
log.Printf("Progress bar update error: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue