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
18
# 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
  error = if klass == Twitter::Error::Forbidden
    handle_forbidden_errors(response)
  else
    klass.from_response(response)
  end
  fail(error)
end