Class: Twitter::Response::RaiseError

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

Instance Method Summary collapse

Constructor Details

#initialize(app, klass) ⇒ RaiseError

Returns a new instance of RaiseError.



23
24
25
26
# File 'lib/twitter/response/raise_error.rb', line 23

def initialize(app, klass)
  @klass = klass
  super(app)
end

Instance Method Details

#on_complete(env) ⇒ Object



17
18
19
20
21
# File 'lib/twitter/response/raise_error.rb', line 17

def on_complete(env)
  status_code = env[:status].to_i
  error_class = @klass.errors[status_code]
  raise error_class.from_response(env) if error_class
end