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
end
def empty?
body.empty?
def blank?
body.blank?
end
def mime_type

@ -35,7 +35,9 @@ module Docs
def process_response?(response)
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
response.success? && response.html? && process_url?(response.effective_url)

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

Loading…
Cancel
Save