Class: HTTP::Features::RaiseError

Inherits:
HTTP::Feature show all
Defined in:
lib/http/features/raise_error.rb

Instance Method Summary collapse

Methods inherited from HTTP::Feature

#on_error, #wrap_request

Constructor Details

#initialize(ignore: []) ⇒ RaiseError

Returns a new instance of RaiseError.



6
7
8
9
10
# File 'lib/http/features/raise_error.rb', line 6

def initialize(ignore: [])
  super()

  @ignore = ignore
end

Instance Method Details

#wrap_response(response) ⇒ Object

Raises:



12
13
14
15
16
17
# File 'lib/http/features/raise_error.rb', line 12

def wrap_response(response)
  return response if response.code < 400
  return response if @ignore.include?(response.code)

  raise HTTP::StatusError, response
end