-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
509 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Faraday | ||
class Response::RaiseErrors < Response::Middleware | ||
def self.register_on_complete(env) | ||
env[:response].on_complete do |response| | ||
case response[:status].to_i | ||
when 400 | ||
raise Twitter::RateLimitExceeded, "(#{response[:status]}): #{response[:body]}" | ||
when 401 | ||
raise Twitter::Unauthorized, "(#{response[:status]}): #{response[:body]}" | ||
when 403 | ||
raise Twitter::General, "(#{response[:status]}): #{response[:body]}" | ||
when 404 | ||
raise Twitter::NotFound, "(#{response[:status]}): #{response[:body]}" | ||
when 500 | ||
raise Twitter::InformTwitter, "Twitter had an internal error. Please let them know in the group. (#{response[:status]}): #{response[:body]}" | ||
when 502..503 | ||
raise Twitter::Unavailable, "(#{response[:status]}): #{response[:body]}" | ||
end | ||
end | ||
end | ||
|
||
def initialize(app) | ||
super | ||
@parser = nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
466a0d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new Unauthenticated class, but shouldn't we forward with depreciation warnings from the Twitter module?
466a0d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. There are some other API changes as well in Geo, Trends, all over the place actually. Let's add the deprecation warnings in master and release them as 0.9.13 ahead of the 1.0.0 (faraday) release.