Class: OpenAmplify::Response::RaiseClientError

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/openamplify/response/raise_client_error.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/openamplify/response/raise_client_error.rb', line 9

def on_complete(env)
  status  = env[:status].to_i
  body    = env[:body]
  headers = env[:response_headers]

  case status
  when 400
    raise OpenAmplify::Error::BadRequest.new body, headers
  when 403
    raise OpenAmplify::Error::Forbidden.new body, headers
  when 413
    raise OpenAmplify::Error::RequestTooLarge.new body, headers
  end
end