History

Improve error logging

Thibaut Courouble committed 9 years ago

Commit 6fc48db1 parent 568ecbd3 files · +11 −9Browse files

Unified · Split

3 files
  1. lib/docs/core/response.rb +2 −2
  2. lib/docs/core/scrapers/url_scraper.rb +3 −1
  3. test/lib/docs/core/response_test.rb +6 −6
lib/docs/core/response.rb+2−2
@@ -8,8 +8,8 @@ module Docs · 7 unmodified lines
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+3−1
@@ -35,7 +35,9 @@ module Docs · 34 unmodified lines
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+6−6
@@ -51,15 +51,15 @@ class DocsResponseTest < MiniTest::Spec · 50 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t