Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added to_s to HttpError and it will display body.

  • Loading branch information...
commit a9f9f686c1cfd8e0cb864617b172ac3c5425eda8 1 parent a034ea5
@treeder treeder authored
Showing with 7 additions and 2 deletions.
  1. +4 −0 lib/rest/errors.rb
  2. +3 −2 test/test_rest.rb
View
4 lib/rest/errors.rb
@@ -18,6 +18,10 @@ def response
def code
response.code
end
+
+ def to_s
+ "HTTP #{code} Error. #{response.body}"
+ end
end
# If it didn't even get a response, it will be a ClientError
View
5 test/test_rest.rb
@@ -51,7 +51,6 @@ def test_gets
p response.headers
assert response.headers.is_a?(Hash)
-
end
def test_404
@@ -65,6 +64,8 @@ def test_404
assert ex.response
assert ex.response.body
assert ex.code == 404
+ assert ex.response.body.include?("404")
+ assert ex.to_s.include?("404")
end
end
@@ -73,7 +74,7 @@ def test_400
response = @rest.get("http://rest-test.iron.io/code/400")
assert false, "shouldn't get here"
rescue Rest::HttpError => ex
- puts "EX: " + ex.inspect
+ puts "EX: #{ex}"
p ex.backtrace
assert ex.is_a?(Rest::HttpError)
assert ex.response
Please sign in to comment.
Something went wrong with that request. Please try again.