Sha256: 736e8b23a176e451be29c168cb467529c085bc268527b0781d946982b3b66468

Contents?: true

Size: 810 Bytes

Versions: 6

Compression:

Stored size: 810 Bytes

Contents

# The Throttled exception gets raised when a throttle is triggered.
#
# The exception carries additional attributes which can be used for
# error tracking and for creating a correct Retry-After HTTP header for
# a 429 response
class Prorate::Throttled < StandardError
  # @attr [String] the name of the throttle (like "shpongs-per-ip").
  #   Can be used to detect which throttle has fired when multiple
  #   throttles are used within the same block.
  attr_reader :throttle_name

  # @attr [Integer] for how long the caller will be blocked, in seconds.
  attr_reader :retry_in_seconds

  def initialize(throttle_name, try_again_in)
    @throttle_name = throttle_name
    @retry_in_seconds = try_again_in
    super("Throttled, please lower your temper and try again in #{retry_in_seconds} seconds")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prorate-0.7.3 lib/prorate/throttled.rb
prorate-0.7.2 lib/prorate/throttled.rb
prorate-0.7.1 lib/prorate/throttled.rb
prorate-0.7.0 lib/prorate/throttled.rb
prorate-0.6.0 lib/prorate/throttled.rb
prorate-0.5.0 lib/prorate/throttled.rb