Sha256: 16bd952195bbbc973d2c8c2cc5db63c8b412a48df4e942cf304f8ebf65e6ab5a
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
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 Thounds::InternalServerError, error_message(response, "Something is technically wrong.") when 502 raise Thounds::BadGateway, error_message(response, "Thounds is down or being upgraded.") when 503 raise Thounds::ServiceUnavailable, error_message(response, "(__-){ Thounds 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[:status].to_s + ':', body].compact.join(' ')} Check http://status.thounds.com/ for updates on the status of the Thounds service." end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thounds-0.0.2 | lib/faraday/raise_http_5xx.rb |
thounds-0.0.1 | lib/faraday/raise_http_5xx.rb |