Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value for exc error #1351

Merged
merged 3 commits into from
Dec 21, 2021
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
2 changes: 1 addition & 1 deletion docs/adapters/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ conn = Faraday.new do |builder|

# test exceptions too
stub.get('/boom') do
raise Faraday::ConnectionFailed, nil
raise Faraday::ConnectionFailed
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion examples/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def sushi(jname, params: {})

it 'handles exception' do
stubs.get('/ebi') do
raise Faraday::ConnectionFailed, nil
raise Faraday::ConnectionFailed
end

expect { client.sushi('ebi') }.to raise_error(Faraday::ConnectionFailed)
Expand Down
2 changes: 1 addition & 1 deletion examples/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_sushi_not_found
def test_sushi_exception
stubs = Faraday::Adapter::Test::Stubs.new
stubs.get('/ebi') do
raise Faraday::ConnectionFailed, nil
raise Faraday::ConnectionFailed
end

cli = client(stubs)
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Faraday
class Error < StandardError
attr_reader :response, :wrapped_exception

def initialize(exc, response = nil)
def initialize(exc = nil, response = nil)
@wrapped_exception = nil unless defined?(@wrapped_exception)
@response = nil unless defined?(@response)
super(exc_msg_and_response!(exc, response))
Expand Down