Exception: Mongo::Error::BulkWriteError
- Inherits:
-
Mongo::Error
- Object
- StandardError
- Mongo::Error
- Mongo::Error::BulkWriteError
- Defined in:
- lib/mongo/error/bulk_write_error.rb
Overview
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.
Constant Summary
Constants inherited from Mongo::Error
BAD_VALUE, CODE, CURSOR_NOT_FOUND, ERRMSG, TRANSIENT_TRANSACTION_ERROR_LABEL, UNKNOWN_ERROR, UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL, WRITE_CONCERN_ERROR, WRITE_CONCERN_ERRORS, WRITE_ERRORS
Instance Attribute Summary collapse
-
#result ⇒ BSON::Document
readonly
Result The error result.
-
#server_addresses ⇒ Array<String>
readonly
Deduplicated list of “host:port” addresses of the servers that produced this bulk write error.
Attributes included from Notable
#connection_global_id, #generation, #service_id
Instance Method Summary collapse
-
#initialize(result, server_addresses: nil) ⇒ BulkWriteError
constructor
Instantiate the new exception.
Methods inherited from Mongo::Error
#change_stream_resumable?, #network_error?, #write_concern_error_label?, #write_concern_error_labels
Methods included from ChangeStreamResumable
Methods included from WriteRetryable
Methods included from Labelable
Methods included from Notable
#add_note, #add_notes, #notes, #to_s
Constructor Details
#initialize(result, server_addresses: nil) ⇒ BulkWriteError
Instantiate the new exception.
54 55 56 57 58 59 60 61 62 |
# File 'lib/mongo/error/bulk_write_error.rb', line 54 def initialize(result, server_addresses: nil) @result = result @server_addresses = normalize_server_addresses(server_addresses) # Exception constructor behaves differently for a nil argument and # for no argument. Avoid passing nil explicitly. = ? super() : super() end |
Instance Attribute Details
#result ⇒ BSON::Document (readonly)
Returns result The error result.
35 36 37 |
# File 'lib/mongo/error/bulk_write_error.rb', line 35 def result @result end |
#server_addresses ⇒ Array<String> (readonly)
Returns Deduplicated list of “host:port” addresses of the servers that produced this bulk write error. Empty when no addresses were supplied.
40 41 42 |
# File 'lib/mongo/error/bulk_write_error.rb', line 40 def server_addresses @server_addresses end |