diff --git a/internal/gateway/github_client.go b/internal/gateway/github_client.go index aaff502..aade3a5 100644 --- a/internal/gateway/github_client.go +++ b/internal/gateway/github_client.go @@ -50,7 +50,7 @@ func (c *GitHubClient) GetPipelineBySha(id, sha string) (*Pipeline, error) { } if len(runs.WorkflowRuns) == 0 { - return nil, fmt.Errorf("no pipelines found") + return nil, fmt.Errorf("no pipelines found for project %s@%s", id, sha) } return workflowToPipeline(runs.WorkflowRuns[0]), nil diff --git a/internal/gateway/gitlab_client.go b/internal/gateway/gitlab_client.go index 896e86f..0697843 100644 --- a/internal/gateway/gitlab_client.go +++ b/internal/gateway/gitlab_client.go @@ -42,7 +42,7 @@ func (c *GitLabClient) GetPipelineBySha(id string, sha string) (*Pipeline, error } if len(pipelines) == 0 { - return nil, fmt.Errorf("no pipelines found") + return nil, fmt.Errorf("no pipelines found for project %s@%s", id, sha) } return &Pipeline{ diff --git a/main.go b/main.go index e244629..449f212 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ func main() { // Define clients gitClient, err := git.New(*fgitDirectoryLoc) if err != nil { - panic(err) + exit(err) } var gatewayClient gateway.Client @@ -45,7 +45,7 @@ func main() { } if err != nil { - panic(err) + exit(err) } // Define service @@ -53,7 +53,7 @@ func main() { // Run polling if err := run(svc, *fpollFrequency); err != nil { - panic(err) + exit(err) } if *fplaySoundOnComplete { @@ -102,3 +102,8 @@ func setFromEnv(name, defaultValue string) string { return defaultValue } + +func exit(err error) { + slog.Error(err.Error()) + os.Exit(1) +}