Exception: Momento::Error::LimitExceededError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Momento::Error::LimitExceededError
- 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
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#transport_details ⇒ Object
readonly
Returns the value of attribute transport_details.
Instance Method Summary collapse
-
#error_cause ⇒ Object
Extract the error cause from metadata.
-
#error_code ⇒ Symbol
A Momento-specific code for the type of error.
-
#initialize(details = '', transport_details = nil) ⇒ LimitExceededError
constructor
A new instance of LimitExceededError.
-
#message ⇒ Object
Generate the appropriate message based on the error cause or details.
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
#details ⇒ Object (readonly)
Returns the value of attribute details.
149 150 151 |
# File 'lib/momento/error/types.rb', line 149 def details @details end |
#transport_details ⇒ Object (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_cause ⇒ Object
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_code ⇒ Symbol
A Momento-specific code for the type of error.
164 165 166 |
# File 'lib/momento/error/types.rb', line 164 def error_code :LIMIT_EXCEEDED_ERROR end |
#message ⇒ Object
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 # First, check for a direct match in the ERROR_CAUSES for the error cause = ErrorMessages::ERROR_CAUSES[error_cause] # If no direct match for error cause, then check if any substring in details matches if .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 || ErrorMessages::UNKNOWN_LIMIT_EXCEEDED end |