class Gems::HTTPError

Base class for HTTP errors from the RubyGems API @api public

Attributes

The HTTP status code @api public @return [Integer] the HTTP status code @example Get the status code

error.code

The HTTP response @api public @return [Net::HTTPResponse] the HTTP response @example Get the response

error.response

Public Class Methods

Initialize a new HTTPError

The message is the response body, or the status message when the body is empty or an HTML page, such as the error page of a CDN.

@api public @param response [Net::HTTPResponse] the HTTP response @return [HTTPError] a new instance @example Create an HTTP error

error = Gems::HTTPError.new(response: response)
Calls superclass method
# File lib/gems/errors/http_error.rb, line 37
def initialize(response:)
  super(error_message(response))
  @response = response
  @code = Integer(response.code)
end

Public Instance Methods

The seconds to wait before retrying the request

RubyGems.org sends a Retry-After header with a 429 Too Many Requests response, and may send one with a 503 Service Unavailable response, as a number of seconds or an HTTP date.

@api public @return [Integer, nil] the seconds to wait, rounded up and never negative, or nil when the response has no

Retry-After header or one that is neither a number of seconds nor an HTTP date

@example Wait before retrying

sleep(error.retry_after || 1)
# File lib/gems/errors/http_error.rb, line 53
def retry_after
  retry_after_of(response)
end