-
-
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.
Conflicts: Gemfile.lock twitter.gemspec
- Loading branch information
Showing
20 changed files
with
517 additions
and
511 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.