Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpolden/echoip.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-12-09 23:08:06 +0300
committerMartin Polden <mpolden@mpolden.no>2020-12-09 23:10:10 +0300
commita4808f1fa4470a384320382b72a9f280475a032e (patch)
tree336eaa51d43822fea74892c3ab8bdff92fa23bf0 /http
parent0d3594284e44ab3506be5322a2289af06cf8453c (diff)
http: Log server errors
Diffstat (limited to 'http')
-rw-r--r--http/http.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/http/http.go b/http/http.go
index 9545dc1..246d3bf 100644
--- a/http/http.go
+++ b/http/http.go
@@ -5,6 +5,7 @@ import (
"fmt"
"html/template"
"io/ioutil"
+ "log"
"path/filepath"
"strings"
@@ -383,6 +384,9 @@ func wrapHandlerFunc(f http.HandlerFunc) appHandler {
func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if e := fn(w, r); e != nil { // e is *appError
// When Content-Type for error is JSON, we need to marshal the response into JSON
+ if e.Code/100 == 5 {
+ log.Println(e.Error)
+ }
if e.IsJSON() {
var data = struct {
Error string `json:"error"`