Add extra logging for errors

This commit is contained in:
Melon 2022-05-16 12:35:31 +01:00
parent 5c1af23f65
commit f414dfdb77
Signed by: melon
GPG Key ID: B0ADD5395BCDAAB6

View File

@ -116,26 +116,26 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util
selRepo = q.Get("repo") selRepo = q.Get("repo")
repo, _, err := giteaClient.GetRepo(myOrg, selRepo) repo, _, err := giteaClient.GetRepo(myOrg, selRepo)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, "GetRepo: "+err.Error(), http.StatusInternalServerError)
return return
} }
refs, _, err := giteaClient.GetRepoRefs(myOrg, selRepo, "heads/"+repo.DefaultBranch) refs, _, err := giteaClient.GetRepoRefs(myOrg, selRepo, "heads/"+repo.DefaultBranch)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, "GetRepoRefs: "+err.Error(), http.StatusInternalServerError)
return return
} }
if len(refs) == 1 { if len(refs) == 1 {
ref := refs[0] ref := refs[0]
commit, _, err := giteaClient.GetSingleCommit(myOrg, selRepo, ref.Object.SHA) commit, _, err := giteaClient.GetSingleCommit(myOrg, selRepo, ref.Object.SHA)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, "GetSingleCommit: "+err.Error(), http.StatusInternalServerError)
return return
} }
selCommitTime = commit.CommitMeta.Created.UTC().Format("20060102150405") selCommitTime = commit.CommitMeta.Created.UTC().Format("20060102150405")
selCommitHash = commit.CommitMeta.SHA[:12] selCommitHash = commit.CommitMeta.SHA[:12]
goMod, _, err := giteaClient.GetFile(myOrg, selRepo, ref.Object.SHA, "go.mod") goMod, _, err := giteaClient.GetFile(myOrg, selRepo, ref.Object.SHA, "go.mod")
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, "go.mod: "+err.Error(), http.StatusInternalServerError)
return return
} }
goModStr := string(goMod) goModStr := string(goMod)