Class: StartupStats::Response::RaiseError

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

Instance Method Summary collapse

Constructor Details

#initialize(app, klass) ⇒ RaiseError

Returns a new instance of RaiseError.



24
25
26
27
# File 'lib/startupstats/response/raise_error.rb', line 24

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

Instance Method Details

#on_complete(env) ⇒ Object



18
19
20
21
22
# File 'lib/startupstats/response/raise_error.rb', line 18

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