diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2019-08-07 11:08:12 -0400 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2019-08-07 13:39:28 -0400 |
commit | d7455e67f5b002de110f7972603906888aff66b8 (patch) | |
tree | 7272978897869431e642faa0f4b20119042984fc /src/mongo/bson/bsonobj.cpp | |
parent | 6978f67e7b4d86cf5cea0970ef7e3f9d8566bb29 (diff) | |
download | mongo-d7455e67f5b002de110f7972603906888aff66b8.tar.gz |
SERVER-42657 Make DataType<BSONObj> noexcept safe
Diffstat (limited to 'src/mongo/bson/bsonobj.cpp')
-rw-r--r-- | src/mongo/bson/bsonobj.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp index 07aab647110..5985ec18976 100644 --- a/src/mongo/bson/bsonobj.cpp +++ b/src/mongo/bson/bsonobj.cpp @@ -622,8 +622,11 @@ void BSONObj::toString( s << (isArray ? " ]" : " }"); } -Status DataType::Handler<BSONObj>::store( - const BSONObj& bson, char* ptr, size_t length, size_t* advanced, std::ptrdiff_t debug_offset) { +Status DataType::Handler<BSONObj>::store(const BSONObj& bson, + char* ptr, + size_t length, + size_t* advanced, + std::ptrdiff_t debug_offset) noexcept try { if (bson.objsize() > static_cast<int>(length)) { str::stream ss; ss << "buffer too small to write bson of size (" << bson.objsize() @@ -640,6 +643,8 @@ Status DataType::Handler<BSONObj>::store( } return Status::OK(); +} catch (const DBException& e) { + return e.toStatus(); } std::ostream& operator<<(std::ostream& s, const BSONObj& o) { |