Skip to content

Commit

Permalink
Restore backward-compatibility layer for errors
Browse files Browse the repository at this point in the history
Faraday has been maintaining a backward-compatibility layer for errors
in the `Faraday::Error::` "namespace". These were removed with v0.16.0,
which caused issues for dependents that use semantic versioning
constraints.

It would be best if these were deprecated with a warning message and
then dropped in v1.0 in order to make sure transitive dependencies do
not break.

See octokit/octokit.rb#1154
  • Loading branch information
michaelherold authored and BobbyMcWho committed Sep 30, 2019
1 parent dcae077 commit 554ddd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/faraday/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,9 @@ class ParsingError < Error
# @see Faraday::Request::Retry
class RetriableResponse < Error
end

%i[ClientError ConnectionFailed ResourceNotFound
ParsingError TimeoutError SSLError RetriableResponse].each do |const|
Error.const_set(const, Faraday.const_get(const))
end
end
6 changes: 6 additions & 0 deletions spec/faraday/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@
it { expect(subject.message).to eq('["error1", "error2"]') }
it { expect(subject.inspect).to eq('#<Faraday::ClientError #<Faraday::ClientError: ["error1", "error2"]>>') }
end

context 'maintains backward-compatibility until 1.0' do
it 'does not raise an error for nested error classes' do
expect { Faraday::Error::ClientError }.not_to raise_error
end
end
end
end

0 comments on commit 554ddd7

Please sign in to comment.