Skip to content

Commit

Permalink
Retry middleware, exceptions option should handle string exception cl…
Browse files Browse the repository at this point in the history
…ass name consistently (lostisland#1334)
  • Loading branch information
jrochkind committed Dec 20, 2021
1 parent 77a4643 commit e6a51f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/faraday/request/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class << matcher
if ex.is_a? Module
error.is_a? ex
else
error.class.to_s == ex.to_s
Object.const_defined?(ex.to_s) && error.is_a?(Object.const_get(ex.to_s))
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions spec/faraday/request/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@

it { expect(times_called).to eq(3) }
end

context 'and this is passed as a string custom exception' do
let(:options) { [{ exceptions: 'StandardError' }] }

it { expect(times_called).to eq(3) }
end

context 'and a non-existent string custom exception is passed' do
let(:options) { [{ exceptions: 'WrongStandardErrorNotExisting' }] }

it { expect(times_called).to eq(1) }
end
end

context 'when an expected error happens' do
Expand Down

0 comments on commit e6a51f0

Please sign in to comment.