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.



18
19
20
21
# File 'lib/faraday/raise_http_5xx.rb', line 18

def initialize(app)
  super
  @parser = nil
end

Class Method Details

.register_on_complete(env) ⇒ Object



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

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