Exception: Mongo::Error::BulkWriteError

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

Overview

Note:

A bulk operation that resulted in a BulkWriteError may have written some of the documents to the database. If the bulk write was unordered, writes may have also continued past the write that produced a BulkWriteError.

Exception raised if there are write errors upon executing a bulk operation.

Unlike OperationFailure, BulkWriteError does not currently expose individual error components (such as the error code). The result document (which can be obtained using the result attribute) provides detailed error information and can be examined by the application if desired.

Since:

  • 2.0.0

Constant Summary

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 collapse

Attributes included from Notable

#connection_global_id, #generation, #service_id

Instance Method Summary collapse

Methods inherited from Mongo::Error

#change_stream_resumable?, #write_concern_error_label?, #write_concern_error_labels

Methods included from ChangeStreamResumable

#change_stream_resumable?

Methods included from WriteRetryable

#write_retryable?

Methods included from Labelable

#add_label, #label?, #labels

Methods included from Notable

#add_note, #add_notes, #notes, #to_s

Constructor Details

#initialize(result) ⇒ BulkWriteError

Instantiate the new exception.

Examples:

Instantiate the exception.

Mongo::Error::BulkWriteError.new(response)

Parameters:

  • result (Hash)

    A processed response from the server reporting results of the operation.

Since:

  • 2.0.0



49
50
51
52
53
54
# File 'lib/mongo/error/bulk_write_error.rb', line 49

def initialize(result)
  @result = result
  # Exception constructor behaves differently for a nil argument and
  # for no argument. Avoid passing nil explicitly.
  super(*[build_message])
end

Instance Attribute Details

#resultBSON::Document (readonly)

Returns result The error result.

Returns:

  • (BSON::Document)

    result The error result.

Since:

  • 2.0.0



38
39
40
# File 'lib/mongo/error/bulk_write_error.rb', line 38

def result
  @result
end