Skip to content

Commit

Permalink
Support faraday v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Jan 21, 2020
1 parent 9f617af commit b85f64a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/pixela/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def connection(request_headers = user_token_headers)

def with_error_handling
yield
rescue Faraday::ClientError => error
rescue *faraday_errors => error
begin
body = JSON.parse(error.response[:body])
raise PixelaError, body["message"]
Expand All @@ -90,6 +90,14 @@ def with_error_handling
end
end

def faraday_errors
if Gem::Version.create(Faraday::VERSION) >= Gem::Version.create("1.0.0")
return [Faraday::ClientError, Faraday::ServerError]
end

[Faraday::Error::ClientError]
end

def default_headers
{
"User-Agent" => "Pixela v#{Pixela::VERSION} (https://github.com/sue445/pixela)",
Expand Down

0 comments on commit b85f64a

Please sign in to comment.