1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 09:59:13 +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:
Jakub Sztandera
2016-05-15 14:46:08 +02:00
parent 74b7fd28ba
commit a77fa94fdf

View File

@ -159,7 +159,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
}
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)
return
}