Skip to content

Commit 6fc48db

Browse files
committed
Improve error logging
1 parent 568ecbd commit 6fc48db

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

lib/docs/core/response.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def error?
88
code == 0 || code != 404 && code != 403 && code >= 400 && code <= 599
99
end
1010

11-
def empty?
12-
body.empty?
11+
def blank?
12+
body.blank?
1313
end
1414

1515
def mime_type

lib/docs/core/scrapers/url_scraper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def request_options
3535

3636
def process_response?(response)
3737
if response.error?
38-
raise "Error status code (#{response.code}): #{response.url}"
38+
raise "Error status code (#{response.code}): #{response.return_message}\n#{response.url}"
39+
elsif response.blank?
40+
raise "Empty response body: #{response.url}"
3941
end
4042

4143
response.success? && response.html? && process_url?(response.effective_url)

test/lib/docs/core/response_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ class DocsResponseTest < MiniTest::Spec
5151
end
5252
end
5353

54-
describe "#empty?" do
55-
it "returns true when the body is empty" do
56-
options.body = ''
57-
assert response.empty?
54+
describe "#blank?" do
55+
it "returns true when the body is blank" do
56+
options.body = ' '
57+
assert response.blank?
5858
end
5959

60-
it "returns false when the body isn't empty" do
60+
it "returns false when the body isn't blank" do
6161
options.body = 'body'
62-
refute response.empty?
62+
refute response.blank?
6363
end
6464
end
6565

0 commit comments

Comments
 (0)