mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-07 09:17:49 +08:00
gateway: degrade error in gateway to log to reduce noise
It logs all errors including expired IPNS keys and other non important errors. License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
1a365a86fe
commit
82d46a5b5b
@ -12,12 +12,12 @@ import (
|
||||
"time"
|
||||
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
"github.com/ipfs/go-ipfs/importer"
|
||||
chunk "github.com/ipfs/go-ipfs/importer/chunk"
|
||||
dag "github.com/ipfs/go-ipfs/merkledag"
|
||||
dagutils "github.com/ipfs/go-ipfs/merkledag/utils"
|
||||
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
"github.com/ipfs/go-ipfs/namesys"
|
||||
path "github.com/ipfs/go-ipfs/path"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
|
||||
@ -166,6 +166,11 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
fmt.Fprint(w, "Could not resolve path. Node is in offline mode.")
|
||||
return
|
||||
} else if err == namesys.ErrResolveFailed {
|
||||
// Don't log that error as it is just noise
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "Path Resolve error: %s", err.Error())
|
||||
return
|
||||
} else if err != nil {
|
||||
webError(w, "Path Resolve error", err, http.StatusBadRequest)
|
||||
return
|
||||
@ -531,7 +536,8 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int)
|
||||
|
||||
func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) {
|
||||
w.WriteHeader(code)
|
||||
log.Errorf("%s: %s", message, err) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe)
|
||||
|
||||
log.Errorf("%s: %s", message, err) // TODO(cryptix): log until we have a better way to expose these (counter metrics maybe)
|
||||
fmt.Fprintf(w, "%s: %s", message, err)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user