[CXX-862] The element and array type operator[] function should not throw Created: 10/Mar/16 Updated: 08/Jan/24 Resolved: 22/Mar/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | API |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | 3.0.1 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Andrew Morrow (Inactive) | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
There is an awkward inconsistency in the operator[] interface for bsoncxx::document::element and bsoncxx::document::array. If element::operator[] or array::operator[] is called and a matching element is not found, we return an invalid element. Similarly, if you call element::operator[] (either overload) and a matching element is not found, we also return an invalid element, as long as the type of the current element is document or array. However, if you call element::operator[] (either overload) on something that is neither a document nor an array, an exception is thrown. This means that a statement like: foo[a][b][c][d] May either throw or return an invalid element, depending on the shape of the document foo. This is pretty hard to handle. We should make it either throw, always, on a missing element, or degrade to an invalid element, always. |
| Comments |
| Comment by Githook User [ 22/Mar/16 ] |
|
Author: {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}Message: |
| Comment by Githook User [ 22/Mar/16 ] |
|
Author: {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}Message: |
| Comment by Githook User [ 22/Mar/16 ] |
|
Author: {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}Message: |
| Comment by Andrew Morrow (Inactive) [ 21/Mar/16 ] |