diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 3bfa74b42..2c6302fb8 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -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) }