Skip to content

Commit

Permalink
Change RelativeLocation to raise TooManyRedirects.
Browse files Browse the repository at this point in the history
ArgumentError isn't the right error to raise in this situation because
it indicates that the arguments passed to a method call are wrong.
  • Loading branch information
Brian Morearty authored and ioquatix committed Dec 11, 2019
1 parent f64be5b commit 474a46f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/async/http/relative_location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

module Async
module HTTP
class TooManyRedirects < StandardError
end

# A client wrapper which transparently handles both relative and absolute redirects to a given maximum number of hops.
class RelativeLocation < ::Protocol::HTTP::Middleware
DEFAULT_METHOD = GET
Expand Down Expand Up @@ -69,7 +72,7 @@ def call(request)
end
end

raise ArgumentError, "Redirected #{hops} times, exceeded maximum!"
raise TooManyRedirects, "Redirected #{hops} times, exceeded maximum!"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/async/http/relative_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
it 'should fail with maximum redirects' do
expect{
response = subject.get('/forever')
}.to raise_error(ArgumentError, /maximum/)
}.to raise_error(Async::HTTP::TooManyRedirects, /maximum/)
end
end

Expand Down

0 comments on commit 474a46f

Please sign in to comment.