Class: AWSCloudSearch::HttpCodeResponseMiddleware

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/aws_cloud_search.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ HttpCodeResponseMiddleware


79
80
81
82
# File 'lib/aws_cloud_search.rb', line 79

def initialize(app)
  super
  @parser = nil
end

Instance Method Details

#on_complete(env) ⇒ Object


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/aws_cloud_search.rb', line 62

def on_complete(env)
  case env[:status]
    when 200..299
      nil
    when 408
      raise RequestTimeout, env[:body]
    when 400..499
      raise HttpClientError, env[:body]
    when 509
      raise BandwidthLimitExceeded, env[:body]
    when 500..599
      raise HttpServerError, env[:body]
    else
      raise UnexpectedHTTPException, env[:body]
  end
end