Skip to content

Commit

Permalink
Raise error on HTTP status code 500.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdvdijk committed Nov 9, 2012
1 parent 173a9a4 commit 267bb32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def evaluate_response(response)
when 204
@logger.debug "OK, no content returned" if @log_enabled
nil
when 400...500
handle_4xx_response(code, body)
when 400..500
handle_4xx_500_response(code, body)
nil
end
end

def handle_4xx_response(code, body)
def handle_4xx_500_response(code, body)
parsed_body = JSON.parse(body)
message = parsed_body["message"]
stacktrace = parsed_body["stacktrace"]
Expand Down
9 changes: 8 additions & 1 deletion spec/unit/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,15 @@ module Neography
}.to raise_error NeographyError
end

end
it "raises BadInputException" do
response = error_response(code: 500, message: "a message", exception: "JsonParseException")
HTTParty.stub(:get).and_return(response)
expect {
connection.get("/foo/bar")
}.to raise_error NeographyError
end

end
end
end
end
Expand Down

0 comments on commit 267bb32

Please sign in to comment.