From a77fa94fdfc1151244ddbbe4fea930bf1258049d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sun, 15 May 2016 14:46:08 +0200 Subject: [PATCH] Make errors more reasonable in case of node in offline mode License: MIT Signed-off-by: Jakub Sztandera --- core/corehttp/gateway_handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index d0366390d..32269a170 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -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 }