Make errors more reasonable in case of node in offline mode
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
May 15, 2016 at 14:46 UTC
a77fa94fdfc1151244ddbbe4fea930bf1258049d
1 file changed
+6
-1
core/corehttp/gateway_handler.go
+6
-1
@@ -159,7 +159,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
159
}
160
161
nd, err := core.Resolve(ctx, i.node, path.Path(urlPath))
162
- if err != nil {
162
+ // If node is in offline mode the error code and message should be different
163
+ if err == core.ErrNoNamesys && !i.node.OnlineMode() {
164
+ w.WriteHeader(http.StatusServiceUnavailable)
165
+ fmt.Fprint(w, "Could not resolve path. Node is in offline mode.")
166
+ return
167
+ } else if err != nil {
168
webError(w, "Path Resolve error", err, http.StatusBadRequest)
169
return
170
}