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

#on_complete(response) ⇒ Object



8
9
10
11
12
13
14
# 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
  raise(handle_forbidden_errors(response)) if klass == Twitter::Error::Forbidden
  raise(klass.from_response(response))
end