Exception: Moped::Errors::PotentialReconfiguration

Inherits:
MongoError
  • Object
show all
Defined in:
lib/moped/errors.rb

Overview

Classes of errors that could be caused by a replica set reconfiguration.

Direct Known Subclasses

OperationFailure, QueryFailure

Constant Summary collapse

NOT_MASTER =

Not master error codes.

[ 13435, 13436, 10009, 15986, 83 ]
CONNECTION_ERRORS_RECONFIGURATION =

Error codes received around reconfiguration

[ 15988, 10276, 11600, 9001, 13639, 10009, 11002, 7 ]

Instance Attribute Summary

Attributes inherited from MongoError

#command, #command The command that generated the error., #details, #details The details about the error.

Instance Method Summary collapse

Methods inherited from MongoError

#initialize

Constructor Details

This class inherits a constructor from Moped::Errors::MongoError

Instance Method Details

#connection_failure?Boolean

Returns:

  • (Boolean)


128
129
130
131
# File 'lib/moped/errors.rb', line 128

def connection_failure?
  err = details["err"] || details["errmsg"] || details["$err"] || ""
  CONNECTION_ERRORS_RECONFIGURATION.include?(details["code"]) || err.include?("could not get last error") || err.include?("connection attempt failed")
end

#ns_not_exists?true, false

Is the error due to a namespace not existing?

Examples:

Doest the namespace not exist?

error.ns_not_exists?

Returns:

  • (true, false)

    If the namespace was not found.

Since:

  • 2.0.0



153
154
155
# File 'lib/moped/errors.rb', line 153

def ns_not_exists?
  details["errmsg"] =~ /namespace does not exist/
end

#ns_not_found?true, false

Is the error due to a namespace not being found?

Examples:

Is the namespace not found?

error.ns_not_found?

Returns:

  • (true, false)

    If the namespace was not found.

Since:

  • 2.0.0



141
142
143
# File 'lib/moped/errors.rb', line 141

def ns_not_found?
  details["errmsg"] == "ns not found"
end

#reconfiguring_replica_set?Boolean

Replica set reconfigurations can be either in the form of an operation error with code 13435, or with an error message stating the server is not a master. (This encapsulates codes 10054, 10056, 10058)

Returns:

  • (Boolean)


123
124
125
126
# File 'lib/moped/errors.rb', line 123

def reconfiguring_replica_set?
  err = details["err"] || details["errmsg"] || details["$err"] || ""
  NOT_MASTER.include?(details["code"]) || err.include?("not master")
end