Exception: Ask::RateLimitError

Inherits:
Error
  • Object
show all
Defined in:
lib/ask/errors.rb

Overview

Raised when the API rate limit is hit. Carries optional category, type, and retry_after for intelligent handling.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, category: nil, rate_limit_type: nil, retry_after: nil) ⇒ RateLimitError

Returns a new instance of RateLimitError.



66
67
68
69
70
71
# File 'lib/ask/errors.rb', line 66

def initialize(message, category: nil, rate_limit_type: nil, retry_after: nil)
  @category = category
  @rate_limit_type = rate_limit_type
  @retry_after = retry_after
  super(message)
end

Instance Attribute Details

#categorySymbol? (readonly)

Returns who rate-limited (:vendor, :local).

Returns:

  • (Symbol, nil)

    who rate-limited (:vendor, :local)



58
59
60
# File 'lib/ask/errors.rb', line 58

def category
  @category
end

#rate_limit_typeSymbol? (readonly)

Returns which limit was hit (:requests, :tokens, :concurrent, :budget).

Returns:

  • (Symbol, nil)

    which limit was hit (:requests, :tokens, :concurrent, :budget)



61
62
63
# File 'lib/ask/errors.rb', line 61

def rate_limit_type
  @rate_limit_type
end

#retry_afterInteger, ... (readonly)

Returns suggested seconds to wait before retrying.

Returns:

  • (Integer, Float, nil)

    suggested seconds to wait before retrying



64
65
66
# File 'lib/ask/errors.rb', line 64

def retry_after
  @retry_after
end