diff --git a/lib/neography/connection.rb b/lib/neography/connection.rb index 3805451..088ea94 100644 --- a/lib/neography/connection.rb +++ b/lib/neography/connection.rb @@ -105,9 +105,15 @@ def evaluate_response(response) end def handle_4xx_500_response(code, body) - parsed_body = JSON.parse(body) - message = parsed_body["message"] - stacktrace = parsed_body["stacktrace"] + if body.nil? or body == "" + parsed_body = {} + message = "No error message returned from server." + stacktrace = "" + else + parsed_body = JSON.parse(body) + message = parsed_body["message"] + stacktrace = parsed_body["stacktrace"] + end @logger.error "#{code} error: #{body}" if @log_enabled diff --git a/spec/integration/rest_index_spec.rb b/spec/integration/rest_index_spec.rb index 2038b51..6e70797 100644 --- a/spec/integration/rest_index_spec.rb +++ b/spec/integration/rest_index_spec.rb @@ -167,6 +167,16 @@ new_index = @neo.get_relationship_index("test_relationship_index", key, value) new_index.should be_nil end + + it "throws an error when there is an empty string in the value when removing a node" do + new_node = @neo.create_node + key = generate_text(6) + value = generate_text + @neo.add_node_to_index("test_node_index", key, value, new_node) + new_index = @neo.get_node_index("test_node_index", key, value) + new_index.should_not be_nil + expect { @neo.remove_node_from_index("test_node_index", key, "", new_node) }.to raise_error Neography::NeographyError + end end describe "get index" do