Exception: Mongo::Error::InvalidUpdateDocument

Inherits:
Mongo::Error
  • Object
show all
Defined in:
build/ruby-driver-v2.18/lib/mongo/error/invalid_update_document.rb

Overview

Exception raised if the object is not a valid update document.

Since:

  • 2.0.0

Constant Summary collapse

MESSAGE =
Deprecated.

The error message.

Since:

  • 2.0.0

'Invalid update document provided'.freeze

Constants inherited from Mongo::Error

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

Instance Attribute Summary

Attributes included from Notable

#connection_global_id, #generation, #service_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mongo::Error

#change_stream_resumable?, #write_concern_error_label?, #write_concern_error_labels

Methods included from Labelable

#add_label, #label?, #labels

Methods included from Notable

#add_note, #notes, #to_s

Constructor Details

#initialize(key: nil) ⇒ InvalidUpdateDocument

Instantiate the new exception.

Parameters:

  • :key (String)

    The invalid key.

Since:

  • 2.0.0



57
58
59
# File 'build/ruby-driver-v2.18/lib/mongo/error/invalid_update_document.rb', line 57

def initialize(key: nil)
  super(self.class.message(key))
end

Class Method Details

.message(key) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Construct the error message.

Parameters:

  • key (String)

    The invalid key.

Returns:

  • (String)

    The error message.

Since:

  • 2.0.0



38
39
40
41
42
# File 'build/ruby-driver-v2.18/lib/mongo/error/invalid_update_document.rb', line 38

def self.message(key)
  message = "Invalid update document provided. Updates documents must only "
  message += "contain only atomic modifiers. The \"#{key}\" key is invalid."
  message
end

.warn(logger, key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Send and cache the warning.

Since:

  • 2.0.0



47
48
49
50
51
52
# File 'build/ruby-driver-v2.18/lib/mongo/error/invalid_update_document.rb', line 47

def self.warn(logger, key)
  @warned ||= begin
    logger.warn(message(key))
    true
  end
end