mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 10:49:24 +08:00
Make errors more reasonable in case of node in offline mode
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
@ -159,7 +159,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
nd, err := core.Resolve(ctx, i.node, path.Path(urlPath))
|
nd, err := core.Resolve(ctx, i.node, path.Path(urlPath))
|
||||||
if err != nil {
|
// If node is in offline mode the error code and message should be different
|
||||||
|
if err == core.ErrNoNamesys && !i.node.OnlineMode() {
|
||||||
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
|
fmt.Fprint(w, "Could not resolve path. Node is in offline mode.")
|
||||||
|
return
|
||||||
|
} else if err != nil {
|
||||||
webError(w, "Path Resolve error", err, http.StatusBadRequest)
|
webError(w, "Path Resolve error", err, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user