http: log internal server errors

This commit is contained in:
Leo Balduf 2016-09-28 02:47:05 -04:00
parent 932281289b
commit d463b235b6

View file

@ -3,6 +3,8 @@ package http
import (
"net/http"
log "github.com/Sirupsen/logrus"
"github.com/chihaya/chihaya/bittorrent"
"github.com/chihaya/chihaya/frontend/http/bencode"
)
@ -12,6 +14,8 @@ func WriteError(w http.ResponseWriter, err error) error {
message := "internal server error"
if _, clientErr := err.(bittorrent.ClientError); clientErr {
message = err.Error()
} else {
log.Errorf("http: internal error: %s", err)
}
w.WriteHeader(http.StatusOK)