<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:15:52 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-7889] Handling data type errors with UserException in MongoDB with the C++ driver</title>
                <link>https://jira.mongodb.org/browse/SERVER-7889</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;According to:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://api.mongodb.org/cplusplus/2.2.0/classmongo_1_1_b_s_o_n_element.html#a692f3eecb505eae2181eb938b7680fbe&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://api.mongodb.org/cplusplus/2.2.0/classmongo_1_1_b_s_o_n_element.html#a692f3eecb505eae2181eb938b7680fbe&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;Double()&lt;/tt&gt; (and like functions) should &quot;throw a &lt;tt&gt;UserException&lt;/tt&gt; if the element is not of the required type.&quot;&lt;/p&gt;

&lt;p&gt;My code:&lt;/p&gt;

&lt;p&gt;{{    BSONObj a_document = BSON(&quot;a_string&quot;&amp;lt;&amp;lt;&quot;A string&quot;);&lt;/p&gt;

&lt;p&gt;    try&lt;/p&gt;
    {
        a_document[&quot;a_string&quot;].Double();
    }
&lt;p&gt;    catch(mongo::UserException ue)&lt;/p&gt;
    {
        cout &amp;lt;&amp;lt; ue.toString() &amp;lt;&amp;lt; endl;
    }
&lt;p&gt;}}&lt;br/&gt;
But it doesn&apos;t get caught. Instead it asserts:&lt;/p&gt;

&lt;p&gt;{{Sun Dec 09 16:04:28 Assertion: 13111:wrong type for field (a_string) 2 != 1&lt;br/&gt;
Sun Dec 09 16:04:28 dev: lastError==0 won&apos;t report:wrong type for field (a_string) 2 != 1}}&lt;/p&gt;

&lt;p&gt;My reading of bsonelement.h indicates it is throwing a &lt;tt&gt;MsgAssertionException&lt;/tt&gt; &amp;#8211; see line 472.&lt;/p&gt;

&lt;p&gt;Is the documentation or my understanding incorrect?&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</description>
                <environment>Windows 7 64 SP1 MongoDB 2.2.0 C++ driver MSVS 2010</environment>
        <key id="58849">SERVER-7889</key>
            <summary>Handling data type errors with UserException in MongoDB with the C++ driver</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="matt.kangas">Matt Kangas</assignee>
                                    <reporter username="therefore">George Thompson</reporter>
                        <labels>
                            <label>pull-request</label>
                    </labels>
                <created>Mon, 10 Dec 2012 18:54:29 +0000</created>
                <updated>Mon, 11 Jul 2016 17:59:17 +0000</updated>
                            <resolved>Tue, 9 Jul 2013 18:48:42 +0000</resolved>
                                    <version>2.2.0</version>
                                    <fixVersion>2.5.1</fixVersion>
                                    <component>Internal Client</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="377337" author="matt.kangas@10gen.com" created="Tue, 9 Jul 2013 18:48:42 +0000"  >&lt;p&gt;Merged in 0e4a3a0c8&lt;/p&gt;</comment>
                            <comment id="377336" author="auto" created="Tue, 9 Jul 2013 18:47:38 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;daveh86&apos;, u&apos;name&apos;: u&apos;daveh86&apos;, u&apos;email&apos;: u&apos;howsdav@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-7889&quot; title=&quot;Handling data type errors with UserException in MongoDB with the C++ driver&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-7889&quot;&gt;&lt;del&gt;SERVER-7889&lt;/del&gt;&lt;/a&gt; change comments to fix api docs&lt;/p&gt;

&lt;p&gt;Change the documented exception thrown by all instances of chk() from&lt;br/&gt;
UserException to MsgAssertionException&lt;/p&gt;

&lt;p&gt;Signed-off-by: Matt Kangas &amp;lt;matt.kangas@10gen.com&amp;gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/0e4a3a0c8439de066a09c3d17f1c23be85b49273&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/0e4a3a0c8439de066a09c3d17f1c23be85b49273&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="219291" author="dan@10gen.com" created="Wed, 19 Dec 2012 14:53:45 +0000"  >&lt;p&gt;The assertion type was changed but not the code&apos;s documentation with this commit: &lt;a href=&quot;https://github.com/mongodb/mongo/commit/f91b04bd34fbbcbdfb3ca0ed06d530068c9205d6&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/f91b04bd34fbbcbdfb3ca0ed06d530068c9205d6&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just need to match them up.&lt;/p&gt;</comment>
                            <comment id="218936" author="david.hows" created="Wed, 19 Dec 2012 04:44:18 +0000"  >&lt;p&gt;Hi Gegorge,&lt;/p&gt;

&lt;p&gt;Your understanding is correct, it throws a &lt;tt&gt;MsgAssertionException&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;I have raised &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-907&quot; title=&quot;C++ driver doc says we throw wrong error type&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-907&quot;&gt;&lt;del&gt;DOCS-907&lt;/del&gt;&lt;/a&gt; to have this one addressed.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;

&lt;p&gt;David&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="59859">DOCS-907</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 19 Dec 2012 04:44:18 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 32 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 32 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>dan@mongodb.com</customfieldvalue>
            <customfieldvalue>david.hows</customfieldvalue>
            <customfieldvalue>therefore</customfieldvalue>
            <customfieldvalue>matt.kangas</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrnf2f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrkzw7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>36294</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10166" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Tests Written</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10153"><![CDATA[Unneeded]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|ht0253:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>