Class: FaradayMiddleware::RaiseHttpException

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RaiseHttpException

Returns a new instance of RaiseHttpException.



15
16
17
18
# File 'lib/faraday/raise_http_exception.rb', line 15

def initialize(app)
  super app
  @parser = nil
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/faraday/raise_http_exception.rb', line 7

def call(env)
  @app.call(env).on_complete do |response|
    if [403, 500, 503].include? response[:status].to_i
      raise NYCGeoClient::Error.new(error_message(response), response[:status].to_i)
    end
  end
end