diff --git a/lib/faraday/request/retry.rb b/lib/faraday/request/retry.rb index 3ba50b7a0..6fac9bba0 100644 --- a/lib/faraday/request/retry.rb +++ b/lib/faraday/request/retry.rb @@ -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 diff --git a/spec/faraday/request/retry_spec.rb b/spec/faraday/request/retry_spec.rb index 5891b73bc..b1399e18e 100644 --- a/spec/faraday/request/retry_spec.rb +++ b/spec/faraday/request/retry_spec.rb @@ -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