Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/dothoop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ module Dothoop
NotFoundError = Class.new(Dothoop::Error)
UnprocessableEntityError = Class.new(Dothoop::Error)
TooManyRequestsError = Class.new(Dothoop::Error)
RedirectError = Class.new(Dothoop::Error)
end
2 changes: 2 additions & 0 deletions lib/dothoop/error_handling_resourcable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ def self.included(base)
default_handler do |response|
if (200...299).include?(response.status)
next
elsif response.status == 301
raise Dothoop::RedirectError.new({status: response.status, body: response.body, redirect: response.headers[:location]})
elsif response.status == 401
raise Dothoop::UnauthorizedError.new("#{response.status}: #{response.body}")
elsif response.status == 403
Expand Down
2 changes: 1 addition & 1 deletion lib/dothoop/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dothoop
VERSION = "0.1.6"
VERSION = "0.1.7"
end
4 changes: 4 additions & 0 deletions test/lib/dothoop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ def test_too_many_requests_error_is_initialized
assert Dothoop::TooManyRequestsError
end

def test_redirect_error_is_initialized
assert Dothoop::RedirectError
end

end
Loading