Module: Momento::Error

Overview

Errors from the Momento client or service, available as ‘response.error`.

Momento::Errors are Exceptions. They can be raised. If the error was caused by an exception, it will be available in #cause.

Examples:

# This is a contrived example to show what you can do with a Momento::Error.
response = client.cache_name(cache_name, key)
if response.error?
  error = response.error

  puts "Creating the cache failed: #{error}"
  puts "The cause was #{error.cause}"
  puts "The details of the error are #{error.details}"
  puts "The error code is #{error.error_code}"

  case error
  when Momento::Error::LimitExceededError
    puts "We'll have to slow down"
  when Momento::Error::PermissionError
    puts "We'll have to fix our auth token"
  when Momento::Error::InvalidArgumentError
    puts "We can't make a cache named #{cache_name}"
  end

  raise error
end

Defined Under Namespace

Classes: AlreadyExistsError, AuthenticationError, BadRequestError, CancelledError, ClientResourceExhaustedError, ConnectionError, FailedPreconditionError, GrpcDetails, InternalServerError, InvalidArgumentError, LimitExceededError, NotFoundError, PermissionError, ServerUnavailableError, TimeoutError, TransportDetails, UnknownError, UnknownServiceError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#causeException

Returns the original exception which was the cause of the error.

Returns:

  • (Exception)

    the original exception which was the cause of the error



33
34
35
# File 'lib/momento/error.rb', line 33

def cause
  @cause
end

#contextHash

Returns any context relevant to the error such as method arguments.

Returns:

  • (Hash)

    any context relevant to the error such as method arguments



35
36
37
# File 'lib/momento/error.rb', line 35

def context
  @context
end

#detailsString

Returns details about the error.

Returns:

  • (String)

    details about the error



39
40
41
# File 'lib/momento/error.rb', line 39

def details
  @details
end

#transport_detailsMomento::Error::TransportDetails

Returns details about the transport layer.

Returns:



37
38
39
# File 'lib/momento/error.rb', line 37

def transport_details
  @transport_details
end

Instance Method Details

#error_codeSymbol

A Momento-specific code for the type of error.

Returns:

  • (Symbol)


# File 'lib/momento/error.rb', line 41

#messageString

The error message.

Returns:

  • (String)


# File 'lib/momento/error.rb', line 45

#to_sString

The error message.

Returns:

  • (String)


50
51
52
# File 'lib/momento/error.rb', line 50

def to_s
  message
end