Commit c111e8aa authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add logError function

parent d88bb4df
......@@ -103,22 +103,22 @@ func handleGetArchive(w http.ResponseWriter, r *gitRequest) {
setArchiveHeaders(w, format, archiveFilename)
w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just return
if _, err := io.Copy(w, archiveReader); err != nil {
log.Printf("handleGetArchive: read: %v", err)
logError(fmt.Errorf("handleGetArchive: read: %v", err))
return
}
if err := archiveCmd.Wait(); err != nil {
log.Printf("handleGetArchive: archiveCmd: %v", err)
logError(fmt.Errorf("handleGetArchive: archiveCmd: %v", err))
return
}
if compressCmd != nil {
if err := compressCmd.Wait(); err != nil {
log.Printf("handleGetArchive: compressCmd: %v", err)
logError(fmt.Errorf("handleGetArchive: compressCmd: %v", err))
return
}
}
if err := finalizeCachedArchive(tempFile, r.ArchivePath); err != nil {
log.Printf("handleGetArchive: finalize cached archive: %v", err)
logError(fmt.Errorf("handleGetArchive: finalize cached archive: %v", err))
return
}
}
......
......@@ -7,7 +7,6 @@ package main
import (
"fmt"
"io"
"log"
"net/http"
"path/filepath"
"strings"
......@@ -40,19 +39,19 @@ func handleGetInfoRefs(w http.ResponseWriter, r *gitRequest) {
w.Header().Add("Cache-Control", "no-cache")
w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just return
if err := pktLine(w, fmt.Sprintf("# service=%s\n", rpc)); err != nil {
log.Printf("handleGetInfoRefs: pktLine: %v", err)
logError(fmt.Errorf("handleGetInfoRefs: pktLine: %v", err))
return
}
if err := pktFlush(w); err != nil {
log.Printf("handleGetInfoRefs: pktFlush: %v", err)
logError(fmt.Errorf("handleGetInfoRefs: pktFlush: %v", err))
return
}
if _, err := io.Copy(w, stdout); err != nil {
log.Printf("handleGetInfoRefs: read from %v: %v", cmd.Args, err)
logError(fmt.Errorf("handleGetInfoRefs: read from %v: %v", cmd.Args, err))
return
}
if err := cmd.Wait(); err != nil {
log.Printf("handleGetInfoRefs: wait for %v: %v", cmd.Args, err)
logError(fmt.Errorf("handleGetInfoRefs: wait for %v: %v", cmd.Args, err))
return
}
}
......@@ -107,11 +106,11 @@ func handlePostRPC(w http.ResponseWriter, r *gitRequest) {
// This io.Copy may take a long time, both for Git push and pull.
if _, err := io.Copy(w, stdout); err != nil {
log.Printf("handlePostRPC read from %v:%v", cmd.Args, err)
logError(fmt.Errorf("handlePostRPC read from %v: %v", cmd.Args, err))
return
}
if err := cmd.Wait(); err != nil {
log.Printf("handlePostRPC wait for %v: %v", cmd.Args, err)
logError(fmt.Errorf("handlePostRPC wait for %v: %v", cmd.Args, err))
return
}
}
......
......@@ -19,12 +19,16 @@ import (
func fail400(w http.ResponseWriter, err error) {
http.Error(w, "Bad request", 400)
log.Print(err)
logError(err)
}
func fail500(w http.ResponseWriter, err error) {
http.Error(w, "Internal server error", 500)
log.Print(err)
logError(err)
}
func logError(err error) {
log.Printf("error: %v", err)
}
// Git subprocess helpers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment