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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.3
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
      None
    • Major Change

      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.

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

              Created:
              Updated:
              Resolved: