1919#include < bsoncxx/v1/array/value.hpp>
2020#include < bsoncxx/v1/document/value.hpp>
2121#include < bsoncxx/v1/document/view.hpp>
22+ #include < bsoncxx/v1/stdx/optional.hpp>
2223#include < bsoncxx/v1/stdx/string_view.hpp>
2324#include < bsoncxx/v1/types/id.hpp>
2425#include < bsoncxx/v1/types/view.hpp>
@@ -185,9 +186,9 @@ std::error_category const& type_error_category() {
185186class exception ::impl {
186187 public:
187188 bsoncxx::v1::array::value _error_labels;
188- bsoncxx::v1::array::value _write_concern_errors;
189- bsoncxx::v1::array::value _write_errors;
190- bsoncxx::v1::array:: value _error_replies ;
189+
190+ // For backward compatibility with v_noabi::operation_exception.
191+ bsoncxx::v1::stdx::optional<bsoncxx::v1::document:: value> _reply ;
191192};
192193
193194bool exception::has_error_label (bsoncxx::v1::stdx::string_view label) const {
@@ -332,32 +333,16 @@ void exception::internal::set_error_labels(exception& self, bsoncxx::v1::documen
332333 set_array_field (" errorLabels" , self._impl ->_error_labels , v);
333334}
334335
335- void exception::internal::set_write_concern_errors (exception& self, bsoncxx::v1::document::view v) {
336- set_array_field (" writeConcernErrors" , self._impl ->_write_concern_errors , v);
337- }
338-
339- void exception::internal::set_write_errors (exception& self, bsoncxx::v1::document::view v) {
340- set_array_field (" writeErrors" , self._impl ->_write_errors , v);
341- }
342-
343- void exception::internal::set_error_replies (exception& self, bsoncxx::v1::document::view v) {
344- set_array_field (" errorReplies" , self._impl ->_error_replies , v);
336+ void exception::internal::set_reply (exception& self, bsoncxx::v1::document::value v) {
337+ self._impl ->_reply = std::move (v);
345338}
346339
347340bsoncxx::v1::array::view exception::internal::get_error_labels (exception const & self) {
348341 return self._impl ->_error_labels ;
349342}
350343
351- bsoncxx::v1::array::view exception::internal::get_write_concern_errors (exception const & self) {
352- return self._impl ->_write_concern_errors ;
353- }
354-
355- bsoncxx::v1::array::view exception::internal::get_write_errors (exception const & self) {
356- return self._impl ->_write_errors ;
357- }
358-
359- bsoncxx::v1::array::view exception::internal::get_error_replies (exception const & self) {
360- return self._impl ->_error_replies ;
344+ bsoncxx::v1::stdx::optional<bsoncxx::v1::document::value> const & exception::internal::get_reply (exception const & self) {
345+ return self._impl ->_reply ;
361346}
362347
363348void throw_exception (bson_error_t const & error) {
@@ -377,9 +362,7 @@ void throw_exception(bson_error_t const& error, bsoncxx::v1::document::value doc
377362 auto ex = make_exception (error);
378363
379364 exception::internal::set_error_labels (ex, doc);
380- exception::internal::set_write_concern_errors (ex, doc);
381- exception::internal::set_write_errors (ex, doc);
382- exception::internal::set_error_replies (ex, doc);
365+ exception::internal::set_reply (ex, std::move (doc));
383366
384367 throw std::move (ex);
385368}
0 commit comments