Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: e7ed9f7830
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (27 sloc) 0.981 kB
require 'faraday'
# @private
module Faraday
# @private
class Response::RaiseHttp5xx < Response::Middleware
def self.register_on_complete(env)
env[:response].on_complete do |response|
case response[:status].to_i
when 500
raise Twitter::InternalServerError, error_message(response, "Something is technically wrong.")
when 502
raise Twitter::BadGateway, error_message(response, "Twitter is down or being upgraded.")
when 503
raise Twitter::ServiceUnavailable, error_message(response, "(__-){ Twitter is over capacity.")
end
end
end
def initialize(app)
super
@parser = nil
end
private
def self.error_message(response, body=nil)
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:response_headers]['status']}:#{(' ' + body) if body} Check http://status.twitter.com/ for updates on the status of the Twitter service."
end
end
end
Jump to Line
Something went wrong with that request. Please try again.