Improve error logging

pull/631/merge
Thibaut Courouble 8 years ago
parent 568ecbd533
commit 6fc48db8af

@ -8,8 +8,8 @@ module Docs
code == 0 || code != 404 && code != 403 && code >= 400 && code <= 599 code == 0 || code != 404 && code != 403 && code >= 400 && code <= 599
end end
def empty? def blank?
body.empty? body.blank?
end end
def mime_type def mime_type

@ -35,7 +35,9 @@ module Docs
def process_response?(response) def process_response?(response)
if response.error? if response.error?
raise "Error status code (#{response.code}): #{response.url}" raise "Error status code (#{response.code}): #{response.return_message}\n#{response.url}"
elsif response.blank?
raise "Empty response body: #{response.url}"
end end
response.success? && response.html? && process_url?(response.effective_url) response.success? && response.html? && process_url?(response.effective_url)

@ -51,15 +51,15 @@ class DocsResponseTest < MiniTest::Spec
end end
end end
describe "#empty?" do describe "#blank?" do
it "returns true when the body is empty" do it "returns true when the body is blank" do
options.body = '' options.body = ' '
assert response.empty? assert response.blank?
end end
it "returns false when the body isn't empty" do it "returns false when the body isn't blank" do
options.body = 'body' options.body = 'body'
refute response.empty? refute response.blank?
end end
end end

Loading…
Cancel
Save