Class: Twitter::REST::Response::RaiseError

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/twitter/rest/response/raise_error.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) on_complete(response)



8
9
10
11
12
13
14
15
16
17
# File 'lib/twitter/rest/response/raise_error.rb', line 8

def on_complete(response)
  status_code = response.status.to_i
  klass = Twitter::Error.errors[status_code]
  return unless klass
  if klass == Twitter::Error::Forbidden
    fail(handle_forbidden_errors(response))
  else
    fail(klass.from_response(response))
  end
end