anchor.diff:                % will do it if our rest config changes.
                 Req:respond({200, add_header(), []});
           Any -> ns_log:log(?MODULE, 0017, "Unexpected error encountered during cluster join ~p", [Any]),
  -               Req:respond({500, add_header(), []})
  +               reply_json(Req, [list_to_binary("Unexpected error encountered during cluster join.")],500)
       end.
   
   %% waits till only one node is left in cluster
  
positive.code:                                             {OtherUser, OtherPswd}) of
                  {ok, undefined, _} ->
                      ns_log:log(?MODULE, 0014, "During node join, remote node returned an invalid response: missing otpCookie."),
                      Req:respond({500, add_header(), "Invalid response from remote node, missing otpCookie."});
                  {ok, _, undefined} ->
                      ns_log:log(?MODULE, 0015, "During node join, remote node returned invalid response: missing otpNode."),
                      Req:respond({500, add_header(), "Invalid response from remote node, missing otpNode."});
                  {ok, Node, Cookie} ->
                      handle_join(Req,
                                  list_to_atom(binary_to_list(Node)),
                                  list_to_atom(binary_to_list(Cookie)));
                  _ -> ns_log:log(?MODULE, 0016, "During node join, the remote node did not return a REST response."),
                       Req:respond({500, add_header(), "Invalid response from remote node."})
              end;
          false ->
              % We are not an 'empty' node, so user should first remove
              % buckets, etc.
              Req:respond({401, add_header(), []})
      end.
  
  handle_join(Req, OtpNode, OtpCookie) ->
  
negative.code:                       {type, Type}, {what, What},
                        {trace, erlang:get_stacktrace()}], % todo: find a way to enable this for field info gathering
              ns_log:log(?MODULE, 0019, "Server error during processing: ~p", Report),
              reply_json(Req, [list_to_binary("Unexpected server error, request logged.")], 500)
      end.
  
  
  