Since: 2.1.0

final class BulkWriteCommandException extends ServerException (View source)

Exception thrown due to failed execution of a MongoDB\Driver\BulkWriteCommand.

The methods of this class provide more details of the error that occurred, including the error reply and partial results from the bulk write.

Properties

protected $message

The error message

from  Exception
protected $code

The error code

from  Exception
protected $file

The filename where the error happened

from  Exception
protected $line

The line where the error happened

from  Exception
protected bool Since: 1.6.0
$errorLabels from  RuntimeException

Methods

__construct(string $message = "", int $code = 0, null|Throwable $previous = null)

Construct the exception. Note: The message is NOT binary safe.

string
getMessage()

Gets the Exception message

int
getCode()

Gets the Exception code

string
getFile()

Gets the file in which the exception occurred

int
getLine()

Gets the line in which the exception occurred

array
getTrace()

Gets the stack trace

null|Throwable
getPrevious()

Returns previous Exception

string
getTraceAsString()

Gets the stack trace as a string

string
__toString()

String representation of the exception

void
__wakeup()

No description

bool
hasErrorLabel(string $label)

Whether the given errorLabel is associated with this exception

Document|null
getErrorReply()

Returns any top-level command error

BulkWriteCommandResult|null
getPartialResult()

Returns the result of any successful write operations

array
getWriteErrors()

Returns any write errors

array
getWriteConcernErrors()

Returns any write concern errors

Details

__construct(string $message = "", int $code = 0, null|Throwable $previous = null)

Construct the exception. Note: The message is NOT binary safe.

Parameters

string $message

[optional] The Exception message to throw.

int $code

[optional] The Exception code.

null|Throwable $previous

[optional] The previous throwable used for the exception chaining.

final string getMessage()

Gets the Exception message

Return Value

string

final int getCode()

Gets the Exception code

Return Value

int

Returns the exception code as integer in {\Exception} but possibly as other type in {\Exception} descendants (for example as string in {\PDOException}).

final string getFile()

Gets the file in which the exception occurred

Return Value

string

Returns the name of the file from which the object was thrown.

final int getLine()

Gets the line in which the exception occurred

Return Value

int

Returns the line number where the thrown object was instantiated.

final array getTrace()

Gets the stack trace

Return Value

array

Returns the stack trace as an array in the same format as {\debug_backtrace()}.

final null|Throwable getPrevious()

Returns previous Exception

Return Value

null|Throwable

Returns the previous {\Throwable} if available, or NULL otherwise.

final string getTraceAsString()

Gets the stack trace as a string

Return Value

string

Returns the stack trace as a string.

string __toString()

String representation of the exception

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

void __wakeup()

No description

Return Value

void

final bool hasErrorLabel(string $label)

Since: 1.6.0

Whether the given errorLabel is associated with this exception

Parameters

string $label

Return Value

bool

final Document|null getErrorReply()

Returns any top-level command error

Return Value

Document|null

Returns any top-level error that occurred when attempting to communicate with the server or execute the bulk write. This value may be null if the exception was thrown due to errors occurring on individual writes.

final BulkWriteCommandResult|null getPartialResult()

Returns the result of any successful write operations

Return Value

BulkWriteCommandResult|null

Returns a MongoDB\Driver\BulkWriteCommandResult reporting the result of any successful operations that were performed before the error was encountered. The return value will be null if it cannot be determined that at least one write was successfully performed (and acknowledged).

final array getWriteErrors()

Returns any write errors

Return Value

array

An array of any MongoDB\Driver\WriteErrors that occurred during the execution of individual write operations. Array keys will correspond to the index of the write operation from MongoDB\Driver\BulkWriteCommand. This map will contain at most one entry if the bulk write was ordered.

final array getWriteConcernErrors()

Returns any write concern errors

Return Value

array

An array of any MongoDB\Driver\WriteConcernErrors that occurred while executing the bulk write. This list may have multiple items if more than one server command was required to execute the bulk write.