Exception: Momento::Error::LimitExceededError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/momento/error/types.rb

Overview

Request rate exceeded the limits for this account.

Defined Under Namespace

Classes: ErrorMessages

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(details = '', transport_details = nil) ⇒ LimitExceededError

Returns a new instance of LimitExceededError.



151
152
153
154
155
# File 'lib/momento/error/types.rb', line 151

def initialize(details = '', transport_details = nil)
  super()
  @details = details.to_s
  @transport_details = transport_details
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



149
150
151
# File 'lib/momento/error/types.rb', line 149

def details
  @details
end

#transport_detailsObject (readonly)

Returns the value of attribute transport_details.



149
150
151
# File 'lib/momento/error/types.rb', line 149

def transport_details
  @transport_details
end

Instance Method Details

#error_causeObject

Extract the error cause from metadata



158
159
160
161
# File 'lib/momento/error/types.rb', line 158

def error_cause
   = transport_details&.grpc&. || {}
  [:err] || 'unknown_error'
end

#error_codeSymbol

A Momento-specific code for the type of error.

Returns:

  • (Symbol)


164
165
166
# File 'lib/momento/error/types.rb', line 164

def error_code
  :LIMIT_EXCEEDED_ERROR
end

#messageObject

Generate the appropriate message based on the error cause or details



199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/momento/error/types.rb', line 199

def message
  # First, check for a direct match in the ERROR_CAUSES for the error cause
  message = ErrorMessages::ERROR_CAUSES[error_cause]

  # If no direct match for error cause, then check if any substring in details matches
  if message.nil?
    ErrorMessages::ERROR_SUBSTRINGS.each do |key, msg|
      return msg if details.include?(key)
    end
  end

  # Return the default message if no match is found
  message || ErrorMessages::UNKNOWN_LIMIT_EXCEEDED
end