Exception: DilisensePepClient::RateLimitError

Inherits:
APIError
  • Object
show all
Defined in:
lib/dilisense_pep_client/errors.rb

Overview

Rate limiting errors

Instance Attribute Summary collapse

Attributes inherited from APIError

#body, #headers, #status

Attributes inherited from Error

#context, #error_code, #request_id, #timestamp

Instance Method Summary collapse

Methods inherited from APIError

#client_error?, #server_error?

Methods inherited from Error

#security_event?, #to_h

Constructor Details

#initialize(message, retry_after: nil, limit: nil, remaining: nil, **options) ⇒ RateLimitError

Returns a new instance of RateLimitError.



265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/dilisense_pep_client/errors.rb', line 265

def initialize(message, retry_after: nil, limit: nil, remaining: nil, **options)
  @retry_after = retry_after
  @limit = limit
  @remaining = remaining
  
  context = {
    retry_after: retry_after,
    rate_limit: limit,
    rate_remaining: remaining,
    reset_time: retry_after ? Time.now + retry_after : nil
  }.merge(options.fetch(:context, {}))
  
  super(message, error_code: "RATE_LIMITED", context: context, **options)
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



263
264
265
# File 'lib/dilisense_pep_client/errors.rb', line 263

def limit
  @limit
end

#remainingObject (readonly)

Returns the value of attribute remaining.



263
264
265
# File 'lib/dilisense_pep_client/errors.rb', line 263

def remaining
  @remaining
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



263
264
265
# File 'lib/dilisense_pep_client/errors.rb', line 263

def retry_after
  @retry_after
end

Instance Method Details

#retryable?Boolean

Returns:

  • (Boolean)


280
281
282
# File 'lib/dilisense_pep_client/errors.rb', line 280

def retryable?
  true
end

#suggested_retry_delayObject



284
285
286
# File 'lib/dilisense_pep_client/errors.rb', line 284

def suggested_retry_delay
  @retry_after || 60 # Default to 60 seconds if not specified
end