Class: Response::RaiseHttp5xx

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/raise_http_5xx.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RaiseHttp5xx

Returns a new instance of RaiseHttp5xx.



20
21
22
23
# File 'lib/faraday/raise_http_5xx.rb', line 20

def initialize(app)
  super
  @parser = nil
end

Class Method Details

.register_on_complete(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/faraday/raise_http_5xx.rb', line 7

def self.register_on_complete(env)
  env[:response].on_complete do |response|
    case response[:status].to_i
    when 500
      raise Slideshare::InternalServerError, error_message(response, "Something is technically wrong.")
    when 502
      raise Slideshare::BadGateway, error_message(response, "Slideshare is down or being upgraded.")
    when 503
      raise Slideshare::ServiceUnavailable, error_message(response, "(__-){ Slideshare is over capacity.")
    end
  end
end