module Http::Exceptions

Constants

VERSION

Public Class Methods

check_response!(res) click to toggle source
# File lib/http/exceptions.rb, line 15
def self.check_response!(res)
  raise HttpException.new(response: res) unless (200...300).include?(res.code.to_i)
  res
end
configuration() click to toggle source

The configuration object. @see Http::Exceptions.configure

# File lib/http/exceptions.rb, line 40
def self.configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source

Call this method to modify defaults in your initializers.

@example

Http::Exceptions.configure do |config|
  config.exceptions_to_convert = [Net::ProtocolError]
  config.exceptions_to_convert << EOFError
end
# File lib/http/exceptions.rb, line 33
def self.configure
  yield(configuration)
  self
end
wrap_and_check() { || ... } click to toggle source
# File lib/http/exceptions.rb, line 20
def self.wrap_and_check
  wrap_exception do
    check_response! yield
  end
end
wrap_exception() { || ... } click to toggle source
# File lib/http/exceptions.rb, line 7
def self.wrap_exception
  begin
    yield
  rescue *configuration.exceptions_to_convert => e
    raise HttpException.new original_exception: e
  end
end