1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-10 07:55:25 +02:00

log github section errors

This commit is contained in:
Elliott Stoneham 2016-06-02 10:40:06 +01:00
parent eb53321e7d
commit 59e40f34c1

View file

@ -79,7 +79,9 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
method := query.Get("method") method := query.Get("method")
if len(method) == 0 { if len(method) == 0 {
writeMessage(w, "gitub", "missing method name") msg := "missing method name"
log.ErrorString("github: " + msg)
writeMessage(w, "gitub", msg)
return return
} }
@ -87,7 +89,9 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
writeMessage(w, "github", "Bad body") msg := "Bad body"
log.ErrorString("github: " + msg)
writeMessage(w, "gitub", msg)
return return
} }
@ -95,6 +99,7 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
err = json.Unmarshal(body, &config) err = json.Unmarshal(body, &config)
if err != nil { if err != nil {
log.Error("github Command Unmarshal", err)
writeError(w, "github", err) writeError(w, "github", err)
return return
} }
@ -102,7 +107,9 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
config.Clean() config.Clean()
if len(config.Token) == 0 { if len(config.Token) == 0 {
writeMessage(w, "github", "Missing token") msg := "Missing token"
log.ErrorString("github: " + msg)
writeMessage(w, "gitub", msg)
return return
} }
@ -114,9 +121,8 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
render, err := t.getCommits(client, config) render, err := t.getCommits(client, config)
if err != nil { if err != nil {
//fmt.Println("Error:", err.Error()) log.Error("github getCommits:", err)
writeError(w, "github", err) writeError(w, "github", err)
// TODO log error
return return
} }
@ -126,16 +132,14 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
me, _, err := client.Users.Get("") me, _, err := client.Users.Get("")
if err != nil { if err != nil {
//fmt.Println(err) log.Error("github get user details:", err)
// TODO log error
writeError(w, "github", err) writeError(w, "github", err)
return return
} }
orgs, _, err := client.Organizations.List("", nil) orgs, _, err := client.Organizations.List("", nil)
if err != nil { if err != nil {
//fmt.Println(err) log.Error("github get user's organisations:", err)
// TODO log error
writeError(w, "github", err) writeError(w, "github", err)
return return
} }
@ -158,8 +162,7 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
repos, _, err = client.Repositories.ListByOrg(vo, opt) repos, _, err = client.Repositories.ListByOrg(vo, opt)
} }
if err != nil { if err != nil {
//fmt.Println(err) log.Error("github get user/org repositories:", err)
// TODO log error
writeError(w, "github", err) writeError(w, "github", err)
return return
} }
@ -180,13 +183,6 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
} }
} }
if err != nil {
//fmt.Println(err)
// TODO log error
writeError(w, "github", err)
return
}
render = sortRepos(render) render = sortRepos(render)
writeJSON(w, render) writeJSON(w, render)
@ -199,8 +195,7 @@ func (t *GithubT) Command(w http.ResponseWriter, r *http.Request) {
branches, _, err := client.Repositories.ListBranches(config.Owner, config.Repo, branches, _, err := client.Repositories.ListBranches(config.Owner, config.Repo,
&gogithub.ListOptions{PerPage: 100}) &gogithub.ListOptions{PerPage: 100})
if err != nil { if err != nil {
//fmt.Println(err) log.Error("github get branch details:", err)
// TODO log error
writeError(w, "github", err) writeError(w, "github", err)
return return
} }
@ -379,14 +374,14 @@ func (*GithubT) Render(config, data string) string {
`) `)
if err != nil { if err != nil {
// TODO log? log.Error("github render template.Parse error:", err)
return "Documize internal github template.Parse error: " + err.Error() return "Documize internal github template.Parse error: " + err.Error()
} }
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)
err = t.Execute(buffer, payload) err = t.Execute(buffer, payload)
if err != nil { if err != nil {
// TODO log? log.Error("github render template.Execute error:", err)
return "Documize internal github template.Execute error: " + err.Error() return "Documize internal github template.Execute error: " + err.Error()
} }