Skip to content

Commit 7714b6d

Browse files
committed
MongoDB\Driver\Exception\BulkWriteCommandException
1 parent a5b72bd commit 7714b6d

File tree

7 files changed

+691
-0
lines changed

7 files changed

+691
-0
lines changed

reference/mongodb/exceptions.xml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
&reference.mongodb.mongodb.driver.exception.authenticationexception;
99
&reference.mongodb.mongodb.driver.exception.bulkwriteexception;
10+
&reference.mongodb.mongodb.driver.exception.bulkwritecommandexception;
1011
&reference.mongodb.mongodb.driver.exception.commandexception;
1112
&reference.mongodb.mongodb.driver.exception.connectionexception;
1213
&reference.mongodb.mongodb.driver.exception.connectiontimeoutexception;
@@ -51,6 +52,7 @@
5152
<listitem>
5253
<simpara><classname>MongoDB\Driver\Exception\ServerException</classname></simpara>
5354
<itemizedlist>
55+
<listitem><simpara><classname>MongoDB\Driver\Exception\BulkWriteCommandException</classname></simpara></listitem>
5456
<listitem><simpara><classname>MongoDB\Driver\Exception\CommandException</classname></simpara></listitem>
5557
<listitem><simpara><classname>MongoDB\Driver\Exception\ExecutionTimeoutException</classname></simpara></listitem>
5658
<listitem>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
4+
<reference xml:id="class.mongodb-driver-exception-bulkwritecommandexception" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
5+
6+
<title>The MongoDB\Driver\Exception\BulkWriteCommandException class</title>
7+
<titleabbrev>MongoDB\Driver\Exception\BulkWriteCommandException</titleabbrev>
8+
9+
<partintro>
10+
11+
<!-- {{{ MongoDB\Driver\Exception\BulkWriteCommandException intro -->
12+
<section xml:id="mongodb-driver-exception-bulkwritecommandexception.intro">
13+
&reftitle.intro;
14+
<para>
15+
Exception thrown due to failed execution of a
16+
<classname>MongoDB\Driver\BulkWriteCommand</classname>.
17+
</para>
18+
</section>
19+
<!-- }}} -->
20+
21+
<section xml:id="mongodb-driver-exception-bulkwritecommandexception.synopsis">
22+
&reftitle.classsynopsis;
23+
24+
<!-- {{{ Synopsis -->
25+
<classsynopsis>
26+
<ooclass><classname>MongoDB\Driver\Exception\BulkWriteCommandException</classname></ooclass>
27+
28+
<!-- {{{ Class synopsis -->
29+
<classsynopsisinfo>
30+
<ooclass>
31+
<classname>MongoDB\Driver\Exception\BulkWriteCommandException</classname>
32+
</ooclass>
33+
34+
<ooclass>
35+
<modifier>extends</modifier>
36+
<classname>MongoDB\Driver\Exception\ServerException</classname>
37+
</ooclass>
38+
39+
<oointerface>
40+
<interfacename>MongoDB\Driver\Exception\Exception</interfacename>
41+
</oointerface>
42+
</classsynopsisinfo>
43+
<!-- }}} -->
44+
<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
45+
<fieldsynopsis>
46+
<modifier>private</modifier>
47+
<type class="union"><type>MongoDB\BSON\Document</type><type>null</type></type>
48+
<varname linkend="mongodb-driver-exception-bulkwritecommandexception.props.errorreply">errorReply</varname>
49+
</fieldsynopsis>
50+
<fieldsynopsis>
51+
<modifier>private</modifier>
52+
<type class="union"><type>MongoDB\Driver\BulkWriteCommandResult</type><type>null</type></type>
53+
<varname linkend="mongodb-driver-exception-bulkwritecommandexception.props.partialresult">errorReply</varname>
54+
</fieldsynopsis>
55+
<fieldsynopsis>
56+
<modifier>private</modifier>
57+
<type>array</type>
58+
<varname linkend="mongodb-driver-exception-bulkwritecommandexception.props.writeconcernerrors">writeConcernErrors</varname>
59+
</fieldsynopsis>
60+
<fieldsynopsis>
61+
<modifier>private</modifier>
62+
<type>array</type>
63+
<varname linkend="mongodb-driver-exception-bulkwritecommandexception.props.writeerrors">writeErrors</varname>
64+
</fieldsynopsis>
65+
66+
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
67+
<!-- <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('mongodb-driver-exception-serverexception.synopsis')/descendant::db:fieldsynopsis)" /> -->
68+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('mongodb-driver-exception-runtimeexception.synopsis')/descendant::db:fieldsynopsis)" />
69+
<!-- <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('runtimeexception.synopsis')/descendant::db:fieldsynopsis)" /> -->
70+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
71+
72+
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
73+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongodb-driver-exception-bulkwritecommandexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
74+
75+
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
76+
<!-- <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongodb-driver-exception-serverexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" /> -->
77+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongodb-driver-exception-runtimeexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
78+
<!-- <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.runtimeexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" /> -->
79+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.exception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
80+
</classsynopsis>
81+
<!-- }}} -->
82+
83+
</section>
84+
85+
<!-- {{{ MongoDB\Driver\Exception\BulkWriteCommandException properties -->
86+
<section xml:id="mongodb-driver-exception-bulkwritecommandexception.props">
87+
&reftitle.properties;
88+
<variablelist>
89+
<varlistentry xml:id="mongodb-driver-exception-bulkwritecommandexception.props.errorreply">
90+
<term><varname>errorReply</varname></term>
91+
<listitem>
92+
<para>
93+
Any top-level error that occurred when attempting to communicate with
94+
the server or execute the bulk write. This value may be &null; if the
95+
exception was thrown due to errors occurring on individual writes.
96+
</para>
97+
</listitem>
98+
</varlistentry>
99+
<varlistentry xml:id="mongodb-driver-exception-bulkwritecommandexception.props.partialresult">
100+
<term><varname>partialResult</varname></term>
101+
<listitem>
102+
<para>
103+
A <classname>MongoDB\Driver\BulkWriteCommandResult</classname> reporting
104+
the result of any successful operations that were performed before the
105+
error was encountered. This value may not &null; if it cannot be
106+
determined that at least one write was successfully performed (and
107+
acknowledged).
108+
</para>
109+
</listitem>
110+
</varlistentry>
111+
<varlistentry xml:id="mongodb-driver-exception-bulkwritecommandexception.props.writeconcernerrors">
112+
<term><varname>writeConcernErrors</varname></term>
113+
<listitem>
114+
<para>
115+
An array of any <classname>MongoDB\Driver\WriteConcernError</classname>s
116+
that occurred while executing the bulk write. This list may have
117+
multiple items if more than one server command was required to execute
118+
the bulk write.
119+
</para>
120+
</listitem>
121+
</varlistentry>
122+
<varlistentry xml:id="mongodb-driver-exception-bulkwritecommandexception.props.writeerrors">
123+
<term><varname>writeErrors</varname></term>
124+
<listitem>
125+
<para>
126+
An array of any <classname>MongoDB\Driver\WriteError</classname>s
127+
that occurred during the execution of individual write operations. Array
128+
keys will correspond to the index of the write operation from
129+
<classname>MongoDB\Driver\BulkWriteCommand</classname>. This map will
130+
contain at most one entry if the bulk write was ordered.
131+
</para>
132+
</listitem>
133+
</varlistentry>
134+
</variablelist>
135+
</section>
136+
<!-- }}} -->
137+
138+
</partintro>
139+
140+
&reference.mongodb.mongodb.driver.exception.entities.bulkwritecommandexception;
141+
142+
</reference>
143+
144+
<!-- Keep this comment at the end of the file
145+
Local variables:
146+
mode: sgml
147+
sgml-omittag:t
148+
sgml-shorttag:t
149+
sgml-minimize-attributes:nil
150+
sgml-always-quote-attributes:t
151+
sgml-indent-step:1
152+
sgml-indent-data:t
153+
indent-tabs-mode:nil
154+
sgml-parent-document:nil
155+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
156+
sgml-exposed-tags:nil
157+
sgml-local-catalogs:nil
158+
sgml-local-ecat-files:nil
159+
End:
160+
vim600: syn=xml fen fdm=syntax fdl=2 si
161+
vim: et tw=78 syn=sgml
162+
vi: ts=1 sw=1
163+
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
4+
<refentry xml:id="mongodb-driver-bulkwritecommandexception.geterrorreply" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5+
<refnamediv>
6+
<refname>MongoDB\Driver\Exception\BulkWriteCommandException::getErrorReply</refname>
7+
<refpurpose>Returns any top-level command error</refpurpose>
8+
</refnamediv>
9+
10+
<refsect1 role="description">
11+
&reftitle.description;
12+
<methodsynopsis>
13+
<modifier>final</modifier> <modifier>public</modifier> <type class="union"><type>MongoDB\BSON\Document</type><type>null</type></type><methodname>MongoDB\Driver\Exception\BulkWriteCommandException::getErrorReply</methodname>
14+
<void />
15+
</methodsynopsis>
16+
<para>
17+
</para>
18+
</refsect1>
19+
20+
<refsect1 role="parameters">
21+
&reftitle.parameters;
22+
&no.function.parameters;
23+
</refsect1>
24+
25+
<refsect1 role="returnvalues">
26+
&reftitle.returnvalues;
27+
<para>
28+
Returns any top-level error that occurred when attempting to communicate
29+
with the server or execute the bulk write. This value may be &null; if the
30+
exception was thrown due to errors occurring on individual writes.
31+
</para>
32+
</refsect1>
33+
34+
<refsect1 role="examples">
35+
&reftitle.examples;
36+
<example>
37+
<title><function>MongoDB\Driver\Exception\BulkWriteCommandException::getErrorReply</function> example</title>
38+
<programlisting role="php">
39+
<![CDATA[
40+
<?php
41+
42+
$manager = new MongoDB\Driver\Manager;
43+
44+
// This example uses configureFailPoint to simulate a top-level command error
45+
$manager->executeCommand('admin', new MongoDB\Driver\Command([
46+
'configureFailPoint' => 'failCommand',
47+
'mode' => ['times' => 1],
48+
'data' => [
49+
'failCommands' => ['bulkWrite'],
50+
'errorCode' => 8, /* UnknownError */
51+
],
52+
]));
53+
54+
$bulk = new MongoDB\Driver\BulkWriteCommand;
55+
$bulk->insertOne('db.coll', ['x' => 1]);
56+
57+
try {
58+
$result = $manager->executeBulkWriteCommand($bulk);
59+
} catch (MongoDB\Driver\Exception\BulkWriteCommandException $e) {
60+
var_dump($e->getErrorReply()?->toPHP());
61+
}
62+
63+
?>
64+
]]>
65+
</programlisting>
66+
&example.outputs.similar;
67+
<screen>
68+
<![CDATA[
69+
object(stdClass)#12 (6) {
70+
["ok"]=>
71+
float(0)
72+
["errmsg"]=>
73+
string(43) "Failing command via 'failCommand' failpoint"
74+
["code"]=>
75+
int(8)
76+
["codeName"]=>
77+
string(12) "UnknownError"
78+
["$clusterTime"]=>
79+
object(stdClass)#10 (2) {
80+
["clusterTime"]=>
81+
object(MongoDB\BSON\Timestamp)#6 (2) {
82+
["increment"]=>
83+
string(1) "7"
84+
["timestamp"]=>
85+
string(10) "1744319389"
86+
}
87+
["signature"]=>
88+
object(stdClass)#9 (2) {
89+
["hash"]=>
90+
object(MongoDB\BSON\Binary)#7 (2) {
91+
["data"]=>
92+
string(20) ""
93+
["type"]=>
94+
int(0)
95+
}
96+
["keyId"]=>
97+
object(MongoDB\BSON\Int64)#8 (1) {
98+
["integer"]=>
99+
string(1) "0"
100+
}
101+
}
102+
}
103+
["operationTime"]=>
104+
object(MongoDB\BSON\Timestamp)#11 (2) {
105+
["increment"]=>
106+
string(1) "7"
107+
["timestamp"]=>
108+
string(10) "1744319389"
109+
}
110+
}
111+
]]>
112+
</screen>
113+
</example>
114+
</refsect1>
115+
116+
<refsect1 role="seealso">
117+
&reftitle.seealso;
118+
<simplelist>
119+
<member><function>MongoDB\Driver\Manager::executeBulkWriteCommand</function></member>
120+
</simplelist>
121+
</refsect1>
122+
123+
</refentry>
124+
125+
<!-- Keep this comment at the end of the file
126+
Local variables:
127+
mode: sgml
128+
sgml-omittag:t
129+
sgml-shorttag:t
130+
sgml-minimize-attributes:nil
131+
sgml-always-quote-attributes:t
132+
sgml-indent-step:1
133+
sgml-indent-data:t
134+
indent-tabs-mode:nil
135+
sgml-parent-document:nil
136+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
137+
sgml-exposed-tags:nil
138+
sgml-local-catalogs:nil
139+
sgml-local-ecat-files:nil
140+
End:
141+
vim600: syn=xml fen fdm=syntax fdl=2 si
142+
vim: et tw=78 syn=sgml
143+
vi: ts=1 sw=1
144+
-->

0 commit comments

Comments
 (0)