Document new exceptions

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332960 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hannes Magnusson 2014-03-11 21:45:16 +00:00
parent 996f0fd83f
commit 36c5526571
8 changed files with 502 additions and 5 deletions

View file

@ -37,5 +37,9 @@ $ sudo update-rc.d umountnfs.sh stop 15 0 6 .
&reference.mongo.mongocursortimeoutexception;
&reference.mongo.mongoconnectionexception;
&reference.mongo.mongogridfsexception;
&reference.mongo.mongoduplicatekeyexception;
&reference.mongo.mongoprotocolexception;
&reference.mongo.mongoexecutiontimeoutexception;
&reference.mongo.mongowriteconcernexception;
</part>

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.mongoduplicatekeyexception" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoDuplicateKeyException class</title>
<titleabbrev>MongoDuplicateKeyException</titleabbrev>
<partintro>
<!-- {{{ MongoDuplicateKeyException intro -->
<section xml:id="mongoduplicatekeyexception.intro">
&reftitle.intro;
<para>
Thrown when attempting to insert a document into a collection which already contains the same values for the <link linkend="mongocollection.ensureindex">unique keys</link>.
</para>
</section>
<!-- }}} -->
<section xml:id="mongoduplicatekeyexception.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoDuplicateKeyException</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>MongoDuplicateKeyException</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>MongoWriteConcernException</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongowriteconcernexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
<section xml:id="mongoduplicatekeyexception.examples">
&reftitle.examples;
<example xml:id="mongoduplicatekeyexception.example.catch">
<title>Catching MongoDuplicateKeyException</title>
<programlisting role="php">
<![CDATA[
<?php
$mc = new MongoClient("localhost");
$c = $mc->selectCollection("test", "test");
$c->insert(array('_id' => 1));
try {
$c->insert(array('_id' => 1));
} catch (MongoWriteConcernException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
&examples.outputs.similar;
<screen>
<![CDATA[
localhost:27017: insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.test.$_id_ dup key: { : 1 }
]]>
</screen>
</example>
</section>
</partintro>
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.mongoexecutiontimeoutexception" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoExecutionTimeoutException class</title>
<titleabbrev>MongoExecutionTimeoutException</titleabbrev>
<partintro>
<!-- {{{ MongoExecutionTimeoutException intro -->
<section xml:id="mongoexecutiontimeoutexception.intro">
&reftitle.intro;
<para>
Throw when a operation times out server side (e.g. in MongoDB).
</para>
<para>
To configure the operation timeout threshold, use <methodname>MongoCursor::maxTimeMS</methodname>
</para>
</section>
<!-- }}} -->
<section xml:id="mongoexecutiontimeoutexception.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoExecutionTimeoutException</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>MongoExecutionTimeoutException</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>MongoException</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.mongoprotocolexception" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoProtocolException class</title>
<titleabbrev>MongoProtocolException</titleabbrev>
<partintro>
<!-- {{{ MongoProtocolException intro -->
<section xml:id="mongoprotocolexception.intro">
&reftitle.intro;
<para>
When talking to MongoDB 2.6.0, and later, certain operations (such as writes) may throw MongoProtocolException when the response
from the server did not make sense - for example during network failure (we could read the entire response) or data corruption.
</para>
<para>
This exception is also thrown when attempting to talk newer protocols then the server supports, for example using the
<classname>MongoWriteBatch</classname> when talking to a MongoDB server prior to 2.6.0.
</para>
</section>
<!-- }}} -->
<section xml:id="mongoprotocolexception.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoProtocolException</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>MongoProtocolException</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>MongoException</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
</classsynopsis>
<!-- }}} -->
</section>
<section xml:id="mongoprotocolexception.examples">
&reftitle.examples;
<example xml:id="mongoprotocolexception.example.catch">
<title>Catching MongoProtocolException</title>
<para>
Running the following example against MongoDB prior to 2.6.0 will throw an MongoProtocolException
</para>
<programlisting role="php">
<![CDATA[
<?php
$mc = new MongoClient("localhost");
$c = $mc->selectCollection("test", "test");
try {
$batch = new MongoInsertBatch($c);
} catch(MongoProtocolException $e) {
echo $e->getMessage();
}
?>
]]>
</programlisting>
&examples.outputs.similar;
<screen>
<![CDATA[
Current primary does not have a Write API
]]>
</screen>
</example>
</section>
</partintro>
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -51,11 +51,6 @@
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongoresultexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
<!--
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongoexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
-->
</classsynopsis>
<!-- }}} -->

View file

@ -32,6 +32,84 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example xml:id="mongoresultexception.getdocument.example.basic">
<title><methodname>MongoResultException::getDocument</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
$mc = new MongoClient("localhost");
$c = $mc->selectCollection("test", "test");
$c->insert(array(
"name" => "Next promo",
"inprogress" => false,
"priority" => 0,
"tasks" => array( "select product", "add inventory", "do placement"),
) );
$c->insert(array(
"name" => "Biz report",
"inprogress" => false,
"priority" => 1,
"tasks" => array( "run sales report", "email report" )
) );
$c->insert(array(
"name" => "Biz report",
"inprogress" => false,
"priority" => 2,
"tasks" => array( "run marketing report", "email report" )
),
array("w" => true)
);
try {
$retval = $c->findAndModify(
array("inprogress" => false, "name" => "Biz report"),
array('$set' => array('$set' => array('inprogress' => true, "started" => new MongoDate()))),
null,
array(
"sort" => array("priority" => -1),
"new" => true,
)
);
} catch(MongoResultException $e) {
echo $e->getMessage(), "\n";
$res = $e->getDocument();
var_dump($res);
}
?>
]]>
</programlisting>
&examples.outputs.similar;
<screen>
<![CDATA[
$set is not valid for storage.
array(3) {
["lastErrorObject"]=>
array(5) {
["connectionId"]=>
int(6)
["err"]=>
string(30) "$set is not valid for storage."
["code"]=>
int(52)
["n"]=>
int(0)
["ok"]=>
float(1)
}
["ok"]=>
float(0)
["errmsg"]=>
string(30) "$set is not valid for storage."
}
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.mongowriteconcernexception" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoWriteConcernException class</title>
<titleabbrev>MongoWriteConcernException</titleabbrev>
<partintro>
<!-- {{{ MongoWriteConcernException intro -->
<section xml:id="mongowriteconcernexception.intro">
&reftitle.intro;
<para>
MongoWriteConcernException is thrown when a write fails. See <xref linkend="mongo.writeconcerns" /> for how to set failure thresholds.
</para>
<para>
Prior to MongoDB 2.6.0 <link xlink:href="&url.mongodb.dochub.getlasterror;"><acronym>GLE</acronym></link> would determin when a write failed.
</para>
</section>
<!-- }}} -->
<section xml:id="mongowriteconcernexception.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoWriteConcernException</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>MongoWriteConcernException</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>MongoCursorException</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongowriteconcernexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongocursorexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.mongo.entities.mongowriteconcernexception;
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongowriteconcernexception.getdocument" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoWriteConcernException::getDocument</refname>
<refpurpose>Get the error document</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>MongoWriteConcernException::getDocument</methodname>
<void />
</methodsynopsis>
<para>
Returns the actual response from the server that was interperated as an error.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A MongoDB document, if available, as an array.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->