Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1089

document::element::operator[] overloads should not throw when given an invalid element

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.0.3
    • BSON
    • None
    • Major Change

    Description

      bsoncxx::document::element::operator[] is documented as non-throwing, however the expression bsoncxx::document::element{}["foo"] throws.

      A fix for this issue was attempted in CXX-862, but the fix was incomplete.

      Original description:

      bsoncxx::document view blubb;

      if( blubb["jolo"] )
      => false

      if( blubb["jolo"][1] )
      terminate called after throwing an instance of 'bsoncxx::v_noabi::exception'
      what(): unset document::element
      For this, can the exception say, that I'm out of bound of a array, or that no array is existing?
      Most awesome would be if the exception would tell the non existing position.

      This behavior is a bit misleading. I would assume for both the upper behavior in just returning a true or false.

      Attachments

        Issue Links

          Activity

            People

              david.golden@mongodb.com David Golden
              Weltenbummler Armin Ball [X]
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: