Exception: Mongo::Error::OperationFailure

Inherits:
Mongo::Error
  • Object
show all
Defined in:
lib/mongo/error/operation_failure.rb

Overview

Raised when an operation fails for some reason.

Since:

  • 2.0.0

Constant Summary collapse

RETRY_MESSAGES =

These are magic error messages that could indicate a cluster reconfiguration behind a mongos. We cannot check error codes as they change between versions, for example 15988 which has 2 completely different meanings between 2.4 and 3.0.

Since:

  • 2.1.1

[
  'transport error',
  'socket exception',
  "can't connect",
  'no master',
  'not master',
  'could not contact primary',
  'connect failed',
  'error querying',
  'could not get last error',
  'connection attempt failed',
  'interrupted at shutdown',
  'unknown replica set',
  'dbclient error communicating with server'
].freeze

Constants inherited from Mongo::Error

BAD_VALUE, CODE, CURSOR_NOT_FOUND, ERR, ERRMSG, ERROR, UNKNOWN_ERROR, WRITE_CONCERN_ERROR, WRITE_CONCERN_ERRORS, WRITE_ERRORS

Instance Method Summary collapse

Instance Method Details

#retryable?true, false

Can the operation that caused the error be retried?

Examples:

Is the error retryable?

error.retryable?

Returns:

  • (true, false)

    If the error is retryable.

Since:

  • 2.1.1



53
54
55
# File 'lib/mongo/error/operation_failure.rb', line 53

def retryable?
  RETRY_MESSAGES.any?{ |m| message.include?(m) }
end