Improve error logging

This commit is contained in:
Henrique Dias 2017-08-01 09:54:41 +01:00
parent 02b9d9f54b
commit 7b4e16fd30
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730

View File

@ -437,18 +437,20 @@ func (m *FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
FI: nil, FI: nil,
}, w, r) }, w, r)
if code != 0 { if code >= 400 {
w.WriteHeader(code) w.WriteHeader(code)
if err != nil { if err == nil {
log.Print(err)
w.Write([]byte(err.Error()))
} else {
txt := http.StatusText(code) txt := http.StatusText(code)
log.Printf("%v: %v %v\n", r.URL.Path, code, txt) log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
w.Write([]byte(txt)) w.Write([]byte(txt))
} }
} }
if err != nil {
log.Print(err)
w.Write([]byte(err.Error()))
}
} }
// Allowed checks if the user has permission to access a directory/file. // Allowed checks if the user has permission to access a directory/file.